diff --git a/ethereum/p2p/build.gradle b/ethereum/p2p/build.gradle index d47b8653c8..9556c62095 100644 --- a/ethereum/p2p/build.gradle +++ b/ethereum/p2p/build.gradle @@ -29,7 +29,7 @@ dependencies { implementation 'com.google.guava:guava' implementation 'io.vertx:vertx-core' implementation 'org.apache.logging.log4j:log4j-api' - implementation 'org.xerial.snappy:snappy-java' + implementation 'org.iq80.snappy:snappy' runtime 'org.apache.logging.log4j:log4j-core' diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/SnappyCompressor.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/SnappyCompressor.java index 3d5bac093b..082691d121 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/SnappyCompressor.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/SnappyCompressor.java @@ -14,9 +14,7 @@ package tech.pegasys.pantheon.ethereum.p2p.rlpx.framing; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.IOException; - -import org.xerial.snappy.Snappy; +import org.iq80.snappy.Snappy; /** * A strategy for compressing and decompressing data with the Snappy algorithm. @@ -28,30 +26,18 @@ public class SnappyCompressor implements Compressor { @Override public byte[] compress(final byte[] uncompressed) { checkNotNull(uncompressed, "input data must not be null"); - try { - return Snappy.compress(uncompressed); - } catch (final IOException e) { - throw new CompressionException("Snappy compression failed", e); - } + return Snappy.compress(uncompressed); } @Override public byte[] decompress(final byte[] compressed) { checkNotNull(compressed, "input data must not be null"); - try { - return Snappy.uncompress(compressed); - } catch (final IOException e) { - throw new CompressionException("Snappy decompression failed", e); - } + return Snappy.uncompress(compressed, 0, compressed.length); } @Override public int uncompressedLength(final byte[] compressed) { checkNotNull(compressed, "input data must not be null"); - try { - return Snappy.uncompressedLength(compressed); - } catch (final IOException e) { - throw new CompressionException("Snappy uncompressedLength failed", e); - } + return Snappy.getUncompressedLength(compressed, 0); } } diff --git a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/FramerTest.java b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/FramerTest.java index ff5089ed7d..904972a850 100644 --- a/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/FramerTest.java +++ b/ethereum/p2p/src/test/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/framing/FramerTest.java @@ -33,8 +33,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import org.iq80.snappy.Snappy; import org.junit.Test; -import org.xerial.snappy.Snappy; public class FramerTest { private static final ObjectMapper MAPPER = new ObjectMapper(); diff --git a/gradle/versions.gradle b/gradle/versions.gradle index cfeb237e43..664cdc5d7b 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -41,7 +41,7 @@ dependencyManagement { dependency('io.pkts:pkts-core:3.0.2') - dependency('org.xerial.snappy:snappy-java:1.1.7.1') + dependency("org.iq80.snappy:snappy:0.4") dependency('com.github.docker-java:docker-java:3.0.14')