From 84d6255d68db27268861c1bf8371217353d7cc94 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 30 Dec 2014 11:07:00 -0500 Subject: [PATCH] NIFI-181: Applied fix that is illustrated in ticket description. If calling LeakyBucketStreamThrottler's InputStream.read(byte[], int, int) and pass 0 as the length, it should just return 0 --- .../apache/nifi/stream/io/LeakyBucketStreamThrottler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java b/commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java index bffbe261dd..ae075b5e30 100644 --- a/commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java +++ b/commons/nifi-utils/src/main/java/org/apache/nifi/stream/io/LeakyBucketStreamThrottler.java @@ -112,6 +112,13 @@ public class LeakyBucketStreamThrottler implements StreamThrottler { @Override public int read(byte[] b, int off, int len) throws IOException { + if ( len < 0 ) { + throw new IllegalArgumentException(); + } + if ( len == 0 ) { + return 0; + } + baos.reset(); final int copied = (int) LeakyBucketStreamThrottler.this.copy(toWrap, baos, len); if (copied == 0) {