Bug+patch: jinterface, OtpInputStream.java: com.ericsson.otp.erlang.OtpErlangDecodeException: Decompression gave n bytes, not ...

John Muellerleile jmuellerleile@REDACTED
Mon Sep 28 02:53:35 CEST 2009


Hi,
R13B01 on Mac OS X, JDK 1.6.0_07, using jinterface to send messages from
erlang to a java node; depending on message size I would encounter:

----
com.ericsson.otp.erlang.OtpErlangDecodeException: Decompression gave 806
bytes, not 1023
at
com.ericsson.otp.erlang.OtpInputStream.read_compressed(OtpInputStream.java:1121)
at com.ericsson.otp.erlang.OtpInputStream.read_any(OtpInputStream.java:1195)
at com.ericsson.otp.erlang.OtpErlangObject.decode(OtpErlangObject.java:70)
[....]
----

After a bit of poking around, the following change to OtpInputStream.java
seems to fix it:

Change OtpInputStream.java, line 1114,1115 from:

final java.util.zip.InflaterInputStream is =
    new java.util.zip.InflaterInputStream(this);

to:

final java.util.zip.InflaterInputStream is =
    new java.util.zip.InflaterInputStream(this, new
java.util.zip.Inflater(), size);

'size' being the important part; the default InflaterInputStream buffer size
is 512 bytes (InflaterInputStream.java, line ~98); seems when the inflater
buffer has filled it returns what has been decompressed so far.  To test, in
OtpInputStream.java place a check for "is.available()" after if(dsize !=
size): if the value returned is 1 there is data remaining to be read.
 Supplying the size established by read4BE() to InflaterInputStream
eliminates this behavior.

John


More information about the erlang-patches mailing list