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

This commit is contained in:
Mark Payne 2014-12-30 11:07:00 -05:00
parent 3997f9b2b0
commit 84d6255d68
1 changed files with 7 additions and 0 deletions

View File

@ -112,6 +112,13 @@ public class LeakyBucketStreamThrottler implements StreamThrottler {
@Override @Override
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
if ( len < 0 ) {
throw new IllegalArgumentException();
}
if ( len == 0 ) {
return 0;
}
baos.reset(); baos.reset();
final int copied = (int) LeakyBucketStreamThrottler.this.copy(toWrap, baos, len); final int copied = (int) LeakyBucketStreamThrottler.this.copy(toWrap, baos, len);
if (copied == 0) { if (copied == 0) {