mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-03 05:51:28 +01:00
Fixed stackoverflow error
This commit is contained in:
parent
62da72e6f1
commit
3711f0ca60
@ -56,7 +56,7 @@ public class ActiveSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FinishedSession toFinishedSession(long end) {
|
public FinishedSession toFinishedSession(long end) {
|
||||||
return new FinishedSession(playerUUID, serverUUID, start, end, afkTime, extraData);
|
return new FinishedSession(playerUUID, serverUUID, start, end, afkTime, extraData.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getPlayerUUID() {
|
public UUID getPlayerUUID() {
|
||||||
|
@ -29,6 +29,10 @@ public class DataMap {
|
|||||||
this.data = new HashMap<>();
|
this.data = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DataMap(Map<String, Object> data) {
|
||||||
|
this.data = new HashMap<>(data);
|
||||||
|
}
|
||||||
|
|
||||||
public <T> void put(Class<T> type, T value) {
|
public <T> void put(Class<T> type, T value) {
|
||||||
data.put(type.getName(), value);
|
data.put(type.getName(), value);
|
||||||
}
|
}
|
||||||
@ -57,4 +61,8 @@ public class DataMap {
|
|||||||
"data=" + data +
|
"data=" + data +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DataMap copy() {
|
||||||
|
return new DataMap(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Player Analytics (Plan).
|
||||||
|
*
|
||||||
|
* Plan is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Plan is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.djrapitops.plan.gathering.domain;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import utilities.RandomData;
|
||||||
|
import utilities.TestConstants;
|
||||||
|
|
||||||
|
class ActiveSessionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void noStackOverflowErrorFromFinishingSession() {
|
||||||
|
ActiveSession session = RandomData.randomUnfinishedSession(TestConstants.SERVER_UUID, TestConstants.WORLDS, TestConstants.PLAYER_ONE_UUID, TestConstants.PLAYER_TWO_UUID);
|
||||||
|
|
||||||
|
FinishedSession finishedSession = session.toFinishedSession(System.currentTimeMillis());
|
||||||
|
|
||||||
|
session.hashCode(); // Error was here
|
||||||
|
finishedSession.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,6 +28,7 @@ import java.util.function.Supplier;
|
|||||||
*/
|
*/
|
||||||
public class TestConstants {
|
public class TestConstants {
|
||||||
|
|
||||||
|
|
||||||
private TestConstants() {
|
private TestConstants() {
|
||||||
/* Static variable class */
|
/* Static variable class */
|
||||||
}
|
}
|
||||||
@ -47,6 +48,7 @@ public class TestConstants {
|
|||||||
public static final Supplier<String> PLAYER_HOSTNAME = () -> "play.example.com";
|
public static final Supplier<String> PLAYER_HOSTNAME = () -> "play.example.com";
|
||||||
|
|
||||||
public static final String WORLD_ONE_NAME = "World One";
|
public static final String WORLD_ONE_NAME = "World One";
|
||||||
|
public static final String[] WORLDS = new String[]{WORLD_ONE_NAME};
|
||||||
public static final Long REGISTER_TIME = RandomData.randomTime();
|
public static final Long REGISTER_TIME = RandomData.randomTime();
|
||||||
|
|
||||||
public static final int SERVER_MAX_PLAYERS = 20;
|
public static final int SERVER_MAX_PLAYERS = 20;
|
||||||
|
Loading…
Reference in New Issue
Block a user