ICU-7057 bug fix: make it actually work when assertions are disabled, tested without -ea

X-SVN-Rev: 35789
This commit is contained in:
Markus Scherer 2014-06-02 15:32:42 +00:00
parent 98772b58a6
commit e91fd1e88e

View File

@ -218,13 +218,14 @@ public final class ICUBinary
try {
int avail = is.available();
byte[] bytes = new byte[avail];
assert avail == is.read(bytes);
int numRead = is.read(bytes);
assert numRead == avail;
while((avail = is.available()) != 0) {
// TODO Java 6 replace new byte[] and arraycopy(): byte[] newBytes = Arrays.copyOf(bytes, bytes.length + avail);
byte[] newBytes = new byte[bytes.length + avail];
System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
int numRead = is.read(newBytes, bytes.length, avail);
assert avail == numRead;
numRead = is.read(newBytes, bytes.length, avail);
assert numRead == avail;
bytes = newBytes;
}
return ByteBuffer.wrap(bytes);