HDFS-13514. Avoid edge case where BUFFER_SIZE is 0

As reported in HDFS-13514, there is a potential bug in the following code block:
```
byte[] data = new byte[BUFFER_SIZE];
long size = 0;
while (size >= 0) {
  size = in.read(data);
}
```
where BUFFER_SIZE is 0
I believe switching to a simple do/while can fix this.
This commit is contained in:
Eric Maynard 2018-04-30 16:37:54 -04:00 committed by GitHub
parent fc074a359c
commit 98fed34e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -84,9 +84,9 @@ public class BenchmarkThroughput extends Configured implements Tool {
InputStream in = new FileInputStream(new File(path.toString()));
byte[] data = new byte[BUFFER_SIZE];
long size = 0;
while (size >= 0) {
do {
size = in.read(data);
}
} while (size > 0);
in.close();
printMeasurements();
}