From eb4ee7a9d4d0f132546b164c3483d62eb9e9f0db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 8 Oct 2015 15:08:33 +1300 Subject: Clean up reported PMD issues --- src/org/traccar/protocol/OrionFrameDecoder.java | 43 ++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'src/org/traccar/protocol/OrionFrameDecoder.java') diff --git a/src/org/traccar/protocol/OrionFrameDecoder.java b/src/org/traccar/protocol/OrionFrameDecoder.java index 033dbd1d5..3babda175 100644 --- a/src/org/traccar/protocol/OrionFrameDecoder.java +++ b/src/org/traccar/protocol/OrionFrameDecoder.java @@ -34,34 +34,33 @@ public class OrionFrameDecoder extends FrameDecoder { int type = buf.getUnsignedByte(buf.readerIndex() + 2) & 0x0f; - if (type == OrionProtocolDecoder.MSG_USERLOG) { - if (buf.readableBytes() >= length + 5) { + if (type == OrionProtocolDecoder.MSG_USERLOG && buf.readableBytes() >= length + 5) { - int index = buf.readerIndex() + 3; - int count = buf.getUnsignedByte(index) & 0x0f; - index += 5; - length += 5; + int index = buf.readerIndex() + 3; + int count = buf.getUnsignedByte(index) & 0x0f; + index += 5; + length += 5; - for (int i = 0; i < count; i++) { - if (buf.readableBytes() < length) { - return null; - } - int logLength = buf.getUnsignedByte(index + 1); - index += logLength; - length += logLength; + for (int i = 0; i < count; i++) { + if (buf.readableBytes() < length) { + return null; } + int logLength = buf.getUnsignedByte(index + 1); + index += logLength; + length += logLength; + } - if (buf.readableBytes() >= length) { - return buf.readBytes(length); - } + if (buf.readableBytes() >= length) { + return buf.readBytes(length); } - } else if (type == OrionProtocolDecoder.MSG_SYSLOG) { - if (buf.readableBytes() >= length + 12) { - length += buf.getUnsignedShort(buf.readerIndex() + 8); - if (buf.readableBytes() >= length) { - return buf.readBytes(length); - } + + } else if (type == OrionProtocolDecoder.MSG_SYSLOG && buf.readableBytes() >= length + 12) { + + length += buf.getUnsignedShort(buf.readerIndex() + 8); + if (buf.readableBytes() >= length) { + return buf.readBytes(length); } + } } -- cgit v1.2.3