From 3c685926df93073d5c5088434132a6f3f844ba32 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 06 Oct 2011 14:15:09 +0000
Subject: [PATCH] Fix OPENDJ-306: Misleading access log error message when client resets the connection.
---
opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
index 5325a38..baa94ad 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
+ * Portions copyright 2011 ForgeRock AS.
*/
package org.opends.server.protocols.asn1;
@@ -330,9 +331,18 @@
}
byteBuffer.clear();
- int read = byteChannel.read(byteBuffer);
- byteBuffer.flip();
- return read;
+ try
+ {
+ int read = byteChannel.read(byteBuffer);
+ return read;
+ }
+ finally
+ {
+ // Make sure that the buffer is flipped even if the read fails in order to
+ // ensure that subsequent calls which query the remaining data return
+ // valid results.
+ byteBuffer.flip();
+ }
}
/**
@@ -362,6 +372,16 @@
}
/**
+ * Returns {@code true} if this ASN.1 reader contains unread data.
+ *
+ * @return {@code true} if this ASN.1 reader contains unread data.
+ */
+ public boolean hasRemainingData()
+ {
+ return (saveBufferReader.remaining() != 0) || (byteBuffer.remaining() != 0);
+ }
+
+ /**
* {@inheritDoc}
*/
public int peekLength() throws ASN1Exception {
--
Gitblit v1.10.0