summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/common/src/main')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java
index 9d98168687..9bafc30ebc 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java
@@ -47,6 +47,7 @@ import org.apache.qpid.protocol.AMQConstant;
*/
public abstract class AMQDecoder<T extends MethodProcessor>
{
+ private static final int MAX_BUFFERS_LIMIT = 10;
private final T _methodProcessor;
/** Holds the protocol initiation decoder. */
@@ -298,6 +299,25 @@ public abstract class AMQDecoder<T extends MethodProcessor>
_remainingBufs.add(new ByteArrayInputStream(remaining));
}
}
+
+ if(_remainingBufs.size() > MAX_BUFFERS_LIMIT)
+ {
+ int totalSize = 0;
+ for(ByteArrayInputStream stream : _remainingBufs)
+ {
+ totalSize += stream.available();
+ }
+
+ byte[] completeBuffer = new byte[totalSize];
+ int pos = 0;
+ for(ByteArrayInputStream stream : _remainingBufs)
+ {
+ pos += stream.read(completeBuffer, pos, stream.available());
+ }
+
+ _remainingBufs.clear();
+ _remainingBufs.add(new ByteArrayInputStream(completeBuffer));
+ }
}
}
}