to avoid NPE

This commit is contained in:
ZZ 2021-08-13 13:25:35 +08:00
parent 085161de17
commit 2117bd2b99

View File

@ -32,10 +32,12 @@ public class ChargingPileEventHandler implements ClientEventHandler {
public void lostConnection(ClientHandler handler) {
String pileNo = ChargingPileServer.getPileNo(handler);
String pkey = "pile:".concat(pileNo);
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
cachePile.put("status", RegisterLogic.DISCONNECTED);
REDIS.setCacheMap(pkey, cachePile);
if (pileNo != null) {
String pkey = "pile:".concat(pileNo);
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
cachePile.put("status", RegisterLogic.DISCONNECTED);
REDIS.setCacheMap(pkey, cachePile);
}
log.info("-> ({}) - [{}] <- {}",
pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
}