问题
- 在应用启动的时候,程序出现异常。存储类的部分字段如下:

- 每分钟进行检测:

- 出现了:

解决
- ConcurrentHashMap 是线程安全,这个问题,是因为 SiegeWarRoomCache 通过 FastJson 存储在 redis中,在启动的时候加载。虽然字段做了
的处理,但是在 FastJson 发序列化的时候,该字段的值被覆盖private Set<Long> roomActors = new ConcurrentHashSet<>();
正确的应该是:public Set<Long> getRoomActors() { return roomActors; } public void setRoomActors(Set<Long> roomActors) { this.roomActors = roomActors; }public Set<Long> getRoomActors() { return roomActors; } public void setRoomActors(Set<Long> roomActors) { this.roomActors.clear(); this.roomActors.addAll(roomActors); }
FastJson 序列化导致的 java.util.ConcurrentModificationException&spm=1001.2101.3001.5002&articleId=156396331&d=1&t=3&u=ba2f00c278834994a24f35f24447d9a8)
5823

被折叠的 条评论
为什么被折叠?



