Skip to content

Commit

Permalink
surround the listConnectedClients with try-catch due to bug in upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
source-c committed Apr 27, 2023
1 parent 30bab2a commit b4ad812
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src-java/com/dkdhub/mqtt_broker/AdvancedBroker.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ public void send(String from, String topic, byte[] data, MqttQoS qos, Boolean re
}

public List<Map<String, ? extends Serializable>> clients() {
return m_server.listConnectedClients().parallelStream()
.map(cl -> Map.of(
"id", cl.getClientID(),
"address", cl.getAddress(),
"port", cl.getPort()))
.collect(Collectors.toUnmodifiableList());
try { // FIXME: this `try-catch to be eliminated once fix will be applied in upstream
return m_server.listConnectedClients().parallelStream()
.map(cl -> Map.of(
"id", cl.getClientID(),
"address", cl.getAddress(),
"port", cl.getPort()))
.collect(Collectors.toUnmodifiableList());
} catch (NullPointerException npe) {
return List.of();
}
}
}

0 comments on commit b4ad812

Please sign in to comment.