mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-03 14:01:47 +01:00
Bugfixes to build 1951 (#2607)
* Remove SecuredRedirectHandler from Jetty * Fixed extension values not updating on PLAYER_LEAVE * Fix Join Address data-truncation errors Affects issues: - Fixed #2606 * Tests for join address truncation
This commit is contained in:
parent
8b32ced181
commit
b68e41bbbe
@ -26,8 +26,6 @@ import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
|
||||
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
|
||||
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
|
||||
import org.eclipse.jetty.server.*;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.SecuredRedirectHandler;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -125,11 +123,7 @@ public class JettyWebserver implements WebServer {
|
||||
connector.setHost(internalIP);
|
||||
webserver.addConnector(connector);
|
||||
|
||||
if (usingHttps) {
|
||||
webserver.setHandler(new HandlerList(new SecuredRedirectHandler(), jettyRequestHandler));
|
||||
} else {
|
||||
webserver.setHandler(jettyRequestHandler);
|
||||
}
|
||||
webserver.setHandler(jettyRequestHandler);
|
||||
|
||||
String startFailure = "Failed to start Jetty webserver: ";
|
||||
try {
|
||||
|
@ -91,6 +91,7 @@ public class ExtensionSvc implements ExtensionService {
|
||||
|
||||
public void registerExtensions() {
|
||||
try {
|
||||
enabled.set(true);
|
||||
extensionRegister.registerBuiltInExtensions(config.getExtensionSettings().getDisabled());
|
||||
} catch (IllegalStateException failedToRegisterOne) {
|
||||
ErrorContext.Builder context = ErrorContext.builder()
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain.event;
|
||||
|
||||
import com.djrapitops.plan.storage.database.sql.tables.JoinAddressTable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ -31,7 +34,7 @@ public class JoinAddress {
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address.get();
|
||||
return StringUtils.truncate(address.get(), JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,7 +107,7 @@ public class PlayerLeaveEventConsumer {
|
||||
|
||||
private void updatePlayerDataExtensionValues(PlayerLeave leave) {
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(
|
||||
leave.getPlayerUUID(), leave.getPlayerName(), CallEvents.PLAYER_JOIN)
|
||||
leave.getPlayerUUID(), leave.getPlayerName(), CallEvents.PLAYER_LEAVE)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -331,6 +331,7 @@ public class LargeStoreQueries {
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.map(JoinAddress::getAddress)
|
||||
.map(joinAddress -> StringUtils.truncate(joinAddress, JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH))
|
||||
.distinct()
|
||||
.filter(address -> !existingJoinAddresses.contains(address))
|
||||
.forEach(address -> {
|
||||
|
@ -24,10 +24,8 @@ import com.djrapitops.plan.storage.database.queries.objects.BaseUserQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.JoinAddressQueries;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.JoinAddressTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreJoinAddressTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
@ -118,6 +116,54 @@ public interface JoinAddressQueriesTest extends DatabaseTestPreparer {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
default void joinAddressIsTruncated() {
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerRegisterTransaction(playerUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
String joinAddress = RandomData.randomString(JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH + RandomData.randomInt(0, 100));
|
||||
session.getExtraData().put(JoinAddress.class, new JoinAddress(joinAddress));
|
||||
db().executeTransaction(new StoreSessionTransaction(session));
|
||||
|
||||
String expectedJoinAddress = StringUtils.truncate(joinAddress, JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH);
|
||||
|
||||
Set<Integer> expected = Set.of(db().query(BaseUserQueries.fetchUserId(playerUUID)).orElseThrow(AssertionError::new));
|
||||
Set<Integer> result = db().query(JoinAddressQueries.userIdsOfPlayersWithJoinAddresses(List.of(expectedJoinAddress)));
|
||||
|
||||
assertEquals(expected, result);
|
||||
|
||||
Map<String, Integer> expectedAddressCounts = Map.of(expectedJoinAddress, 1);
|
||||
Map<String, Integer> resultAddressCounts = db().query(JoinAddressQueries.latestJoinAddresses());
|
||||
|
||||
assertEquals(expectedAddressCounts, resultAddressCounts);
|
||||
}
|
||||
|
||||
@Test
|
||||
default void joinAddressIsTruncatedWhenStoringSessionsAfterRestart() {
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[0]));
|
||||
db().executeTransaction(new StoreWorldNameTransaction(serverUUID(), worlds[1]));
|
||||
db().executeTransaction(new PlayerRegisterTransaction(playerUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME));
|
||||
|
||||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
|
||||
String joinAddress = RandomData.randomString(JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH + RandomData.randomInt(0, 100));
|
||||
session.getExtraData().put(JoinAddress.class, new JoinAddress(joinAddress));
|
||||
db().executeTransaction(new ShutdownDataPreservationTransaction(List.of(session)));
|
||||
|
||||
String expectedJoinAddress = StringUtils.truncate(joinAddress, JoinAddressTable.JOIN_ADDRESS_MAX_LENGTH);
|
||||
|
||||
Set<Integer> expected = Set.of(db().query(BaseUserQueries.fetchUserId(playerUUID)).orElseThrow(AssertionError::new));
|
||||
Set<Integer> result = db().query(JoinAddressQueries.userIdsOfPlayersWithJoinAddresses(List.of(expectedJoinAddress)));
|
||||
|
||||
assertEquals(expected, result);
|
||||
|
||||
Map<String, Integer> expectedAddressCounts = Map.of(expectedJoinAddress, 1);
|
||||
Map<String, Integer> resultAddressCounts = db().query(JoinAddressQueries.latestJoinAddresses());
|
||||
|
||||
assertEquals(expectedAddressCounts, resultAddressCounts);
|
||||
}
|
||||
|
||||
@Test
|
||||
default void joinAddressUpdateIsUniquePerServer() {
|
||||
joinAddressCanBeUnknown();
|
||||
|
Loading…
Reference in New Issue
Block a user