From 2c3c794af6e9ab05febad02bfe2daffd703a2175 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 29 Jan 2015 15:13:38 +0000
Subject: [PATCH] AutoRefactor'ed code cleanups

---
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/ASN1BufferReader.java |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/ASN1BufferReader.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/ASN1BufferReader.java
index 188a37c..d0b8aef 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/ASN1BufferReader.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/ASN1BufferReader.java
@@ -54,7 +54,7 @@
         private int bytesRead;
 
         public void checkLimit(final int readSize) throws IOException {
-            if ((readLimit > 0) && (bytesRead + readSize > readLimit)) {
+            if (0 < readLimit && readLimit < bytesRead + readSize) {
                 final LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get();
                 throw DecodeException.fatalError(message);
             }
@@ -178,14 +178,11 @@
      *             If an error occurs while trying to decode an ASN1 element.
      */
     public boolean elementAvailable() throws IOException {
-        return !((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE)
-                        && !needTypeState(true))
-                && !((state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
-                        && !needFirstLengthByteState(true))
-                && !((state == ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES)
-                        && !needAdditionalLengthBytesState(true))
+        return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(true))
+                && (state != ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE || needFirstLengthByteState(true))
+                && (state != ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES
+                    || needAdditionalLengthBytesState(true))
                 && peekLength <= readLimiter.remaining();
-
     }
 
     /**
@@ -198,7 +195,7 @@
      *             If an error occurs while trying to decode an ASN1 element.
      */
     public boolean hasNextElement() throws IOException {
-        return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true);
+        return state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(true);
     }
 
     /** {@inheritDoc} */

--
Gitblit v1.10.0