diff --git a/.travis.yml b/.travis.yml index c14f1061..1f80e9d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,13 @@ language: scala scala: - - 2.11.1 + - 2.11.7 + +sudo: false + jdk: - openjdk6 - openjdk7 - oraclejdk7 - -branches: - only: - - master - - develop + - oraclejdk8 script: ./sbt test - diff --git a/project/build.properties b/project/build.properties index 07b0ebbc..02cb92b3 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ -sbt.version=0.13.8 +sbt.version=0.13.9 diff --git a/src/main/java/org/xerial/snappy/SnappyInputStream.java b/src/main/java/org/xerial/snappy/SnappyInputStream.java index a7380362..19a68c66 100755 --- a/src/main/java/org/xerial/snappy/SnappyInputStream.java +++ b/src/main/java/org/xerial/snappy/SnappyInputStream.java @@ -157,10 +157,27 @@ protected void readFully(byte[] fragment, int fragmentLength) * @see java.io.InputStream#read(byte[], int, int) */ @Override - public int read(byte[] b, int off, int len) + public int read(byte[] b, int byteOffset, int byteLength) throws IOException { - return rawRead(b, off, len); + int writtenBytes = 0; + for (; writtenBytes < byteLength; ) { + + if (uncompressedCursor >= uncompressedLimit) { + if (hasNextChunk()) { + continue; + } + else { + return writtenBytes == 0 ? -1 : writtenBytes; + } + } + int bytesToWrite = Math.min(uncompressedLimit - uncompressedCursor, byteLength - writtenBytes); + System.arraycopy(uncompressed, uncompressedCursor, b, byteOffset + writtenBytes, bytesToWrite); + writtenBytes += bytesToWrite; + uncompressedCursor += bytesToWrite; + } + + return writtenBytes; } /**