aboutsummaryrefslogtreecommitdiffstats
path: root/lib/jinterface/java_src/com/ericsson/otp
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2012-10-18 12:29:24 +0200
committerHenrik Nord <[email protected]>2012-10-18 12:29:28 +0200
commit9a993c9479b94309861b7620d56fd12cfcab5740 (patch)
tree1821803793ddc87c2076b60c6c971a94096abc3e /lib/jinterface/java_src/com/ericsson/otp
parentf0332a299d3c6eea7089483f05a7e6f580e40f3c (diff)
parent54b85a7cb1eafcbc1c0116eaf21e05f1810db388 (diff)
downloadotp-9a993c9479b94309861b7620d56fd12cfcab5740.tar.gz
otp-9a993c9479b94309861b7620d56fd12cfcab5740.tar.bz2
otp-9a993c9479b94309861b7620d56fd12cfcab5740.zip
Merge branch 'nk/jinterface-fix_compressed_binary'
* nk/jinterface-fix_compressed_binary: add (de)compress roundtrip tests with larger values fix reading compressed binary terms from Java OTP-10505
Diffstat (limited to 'lib/jinterface/java_src/com/ericsson/otp')
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java
index b9b43481ee..ae5f4ee072 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpInputStream.java
@@ -1112,12 +1112,16 @@ public class OtpInputStream extends ByteArrayInputStream {
final int size = read4BE();
final byte[] buf = new byte[size];
final java.util.zip.InflaterInputStream is =
- new java.util.zip.InflaterInputStream(this);
+ new java.util.zip.InflaterInputStream(this, new java.util.zip.Inflater(), size);
+ int curPos = 0;
try {
- final int dsize = is.read(buf, 0, size);
- if (dsize != size) {
+ int curRead;
+ while(curPos < size && (curRead = is.read(buf, curPos, size - curPos)) != -1) {
+ curPos += curRead;
+ }
+ if (curPos != size) {
throw new OtpErlangDecodeException("Decompression gave "
- + dsize + " bytes, not " + size);
+ + curPos + " bytes, not " + size);
}
} catch (final IOException e) {
throw new OtpErlangDecodeException("Cannot read from input stream");