toString()-Aufruf in try/catch, damit eine nicht darstellbare SyslogMessage die Broker-Verbindung nicht trennt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>marwe
parent
8a9b9f9dba
commit
b9a17a82af
|
|
@ -82,6 +82,17 @@ public class MqttAdapter {
|
|||
void verarbeite(byte[] payload) {
|
||||
SyslogDecoder.decode(payload)
|
||||
.filter(SyslogDecoder::isRelevant)
|
||||
.ifPresent(m -> ziel.accept(m.toString()));
|
||||
.ifPresent(m -> {
|
||||
String text;
|
||||
try {
|
||||
text = m.toString();
|
||||
} catch (RuntimeException e) {
|
||||
// z.B. host == null -> NullPointerException; ohne catch
|
||||
// würde Paho die Broker-Verbindung trennen
|
||||
System.err.println("SyslogMessage nicht darstellbar: " + e);
|
||||
return;
|
||||
}
|
||||
ziel.accept(text);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue