下面left()方法, 很奇怪, 在遍历中移除竟然没报错, 猜测是 线程池submit吃掉了异常, 具体没深入看.
public abstract class AbstractWsHandler implements WsHandler {
protected Set<String> rooms;
public void left(String room) {
if (!Strings.isBlank(room)) {
rooms.remove(room);
room = prefix + room;
log.debugf("session(id=%s) left room(name=%s)", session.getId(), room);
roomProvider.left(room, session.getId());
}
}
public void depose() {
for (String room : rooms) {
left(room);
}
}
}
建议改成
for (Object room : mRooms.toArray()) {
left(String.valueOf(room));
}