From e91fd1e88e04ddbb78937a254a45ea7d367fa6dd Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Mon, 2 Jun 2014 15:32:42 +0000 Subject: [PATCH] ICU-7057 bug fix: make it actually work when assertions are disabled, tested without -ea X-SVN-Rev: 35789 --- .../main/classes/core/src/com/ibm/icu/impl/ICUBinary.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java index 57d4c05dea..764df4a8b1 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java @@ -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);