mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-01-17 00:06:00 -05:00
Switching HashMap to ConcurrentHashMap to address ConcurrentModificationException on server start
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -4,6 +4,8 @@
|
||||
Holocore.iml
|
||||
out
|
||||
.idea
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# Gradle
|
||||
build
|
||||
@@ -14,5 +16,6 @@ build
|
||||
/log/
|
||||
/cfg/
|
||||
/odb/
|
||||
/bin/
|
||||
*.db
|
||||
*.iff
|
||||
|
||||
@@ -52,6 +52,7 @@ import me.joshlarson.jlcommon.log.Log;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TravelHelper {
|
||||
|
||||
@@ -61,7 +62,7 @@ public class TravelHelper {
|
||||
private final TravelPointManager pointManager;
|
||||
|
||||
public TravelHelper() {
|
||||
this.travel = new HashMap<>();
|
||||
this.travel = new ConcurrentHashMap<>();
|
||||
this.travelExecutor = new ThreadPool(3, "travel-shuttles-%d");
|
||||
this.routeManager = new AllowedRouteManager();
|
||||
this.pointManager = new TravelPointManager();
|
||||
@@ -268,11 +269,11 @@ public class TravelHelper {
|
||||
private final Map<Terrain, Map<Terrain, Integer>> routeCosts;
|
||||
|
||||
public AllowedRouteManager() {
|
||||
this.routeCosts = new HashMap<>();
|
||||
this.routeCosts = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public void addRoute(Terrain departure, Terrain destination, int fee) {
|
||||
Map<Terrain, Integer> departureCosts = routeCosts.computeIfAbsent(departure, k -> new HashMap<>());
|
||||
Map<Terrain, Integer> departureCosts = routeCosts.computeIfAbsent(departure, k -> new ConcurrentHashMap<>());
|
||||
departureCosts.put(destination, fee);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TravelPointManager {
|
||||
|
||||
@@ -40,8 +41,8 @@ public class TravelPointManager {
|
||||
private final Map<Terrain, List<TravelPoint>> starportPoints;
|
||||
|
||||
public TravelPointManager() {
|
||||
this.shuttlePoints = new HashMap<>();
|
||||
this.starportPoints = new HashMap<>();
|
||||
this.shuttlePoints = new ConcurrentHashMap<>();
|
||||
this.starportPoints = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public void addTravelPoint(TravelPoint point) {
|
||||
|
||||
Reference in New Issue
Block a user