diff options
Diffstat (limited to 'src/main/java/org/traccar/ExtendedObjectDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/ExtendedObjectDecoder.java | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/ExtendedObjectDecoder.java b/src/main/java/org/traccar/ExtendedObjectDecoder.java index 9468e2fff..8d693c7cf 100644 --- a/src/main/java/org/traccar/ExtendedObjectDecoder.java +++ b/src/main/java/org/traccar/ExtendedObjectDecoder.java @@ -54,14 +54,12 @@ public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter } private void saveOriginal(Object decodedMessage, Object originalMessage) { - if (getConfig().getBoolean(Keys.DATABASE_SAVE_ORIGINAL) && decodedMessage instanceof Position) { - Position position = (Position) decodedMessage; - if (originalMessage instanceof ByteBuf) { - ByteBuf buf = (ByteBuf) originalMessage; + if (getConfig().getBoolean(Keys.DATABASE_SAVE_ORIGINAL) && decodedMessage instanceof Position position) { + if (originalMessage instanceof ByteBuf buf) { position.set(Position.KEY_ORIGINAL, ByteBufUtil.hexDump(buf, 0, buf.writerIndex())); - } else if (originalMessage instanceof String) { + } else if (originalMessage instanceof String stringMessage) { position.set(Position.KEY_ORIGINAL, DataConverter.printHex( - ((String) originalMessage).getBytes(StandardCharsets.US_ASCII))); + stringMessage.getBytes(StandardCharsets.US_ASCII))); } } } @@ -78,8 +76,7 @@ public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter decodedMessage = handleEmptyMessage(ctx.channel(), networkMessage.getRemoteAddress(), originalMessage); } if (decodedMessage != null) { - if (decodedMessage instanceof Collection) { - var collection = (Collection) decodedMessage; + if (decodedMessage instanceof Collection collection) { ctx.writeAndFlush(new AcknowledgementHandler.EventDecoded(collection)); for (Object o : collection) { saveOriginal(o, originalMessage); |