diff --git a/core/java/src/net/i2p/client/I2PSessionImpl2.java b/core/java/src/net/i2p/client/I2PSessionImpl2.java index 6e806e001..5def001a8 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl2.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl2.java @@ -10,6 +10,7 @@ package net.i2p.client; */ import java.io.InputStream; +import java.io.IOException; import java.util.HashSet; import java.util.Iterator; import java.util.Properties; @@ -86,10 +87,15 @@ class I2PSessionImpl2 extends I2PSessionImpl { */ public byte[] receiveMessage(int msgId) throws I2PSessionException { byte compressed[] = super.receiveMessage(msgId); - if (SHOULD_COMPRESS) - return DataHelper.decompress(compressed); - else + if (SHOULD_COMPRESS) { + try { + return DataHelper.decompress(compressed); + } catch (IOException ioe) { + throw new I2PSessionException("Error decompressing message", ioe); + } + } else { return compressed; + } } private boolean sendBestEffort(Destination dest, byte payload[], SessionKey keyUsed, Set tagsSent) diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 9d725886d..5dfef9659 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -552,25 +552,20 @@ public class DataHelper { } /** decompress the GZIP compressed data (returning null on error) */ - public static byte[] decompress(byte orig[]) { + public static byte[] decompress(byte orig[]) throws IOException { if ((orig == null) || (orig.length <= 0)) return orig; - try { - GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(orig), orig.length); - ByteArrayOutputStream baos = new ByteArrayOutputStream(orig.length * 2); - byte buf[] = new byte[4 * 1024]; - while (true) { - int read = in.read(buf); - if (read == -1) break; - baos.write(buf, 0, read); - } - byte rv[] = baos.toByteArray(); - //if (_log.shouldLog(Log.DEBUG)) - // _log.debug("Decompression of " + orig.length + " into " + rv.length + " (or " + 100.0d - // * (((double) rv.length) / ((double) orig.length)) + "% savings)"); - return rv; - } catch (IOException ioe) { - //_log.error("Error decompressing?", ioe); - return null; + GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(orig), orig.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(orig.length * 2); + byte buf[] = new byte[4 * 1024]; + while (true) { + int read = in.read(buf); + if (read == -1) break; + baos.write(buf, 0, read); } + byte rv[] = baos.toByteArray(); + //if (_log.shouldLog(Log.DEBUG)) + // _log.debug("Decompression of " + orig.length + " into " + rv.length + " (or " + 100.0d + // * (((double) rv.length) / ((double) orig.length)) + "% savings)"); + return rv; } } \ No newline at end of file