aboutsummaryrefslogtreecommitdiff
path: root/other
diff options
context:
space:
mode:
Diffstat (limited to 'other')
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/Gzip.java14
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java4
2 files changed, 13 insertions, 5 deletions
diff --git a/other/java/client/src/main/java/seaweedfs/client/Gzip.java b/other/java/client/src/main/java/seaweedfs/client/Gzip.java
index 248285dd3..4909094f5 100644
--- a/other/java/client/src/main/java/seaweedfs/client/Gzip.java
+++ b/other/java/client/src/main/java/seaweedfs/client/Gzip.java
@@ -18,14 +18,18 @@ public class Gzip {
return compressed;
}
- public static byte[] decompress(byte[] compressed) throws IOException {
- ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
- GZIPInputStream gis = new GZIPInputStream(bis);
- return readAll(gis);
+ public static byte[] decompress(byte[] compressed) {
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
+ GZIPInputStream gis = new GZIPInputStream(bis);
+ return readAll(gis);
+ } catch (Exception e) {
+ return compressed;
+ }
}
private static byte[] readAll(InputStream input) throws IOException {
- try( ByteArrayOutputStream output = new ByteArrayOutputStream()){
+ try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
byte[] buffer = new byte[4096];
int n;
while (-1 != (n = input.read(buffer))) {
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
index fa44ee4af..cd2f55678 100644
--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
@@ -119,6 +119,10 @@ public class SeaweedRead {
}
}
+ if (chunkView.isCompressed) {
+ data = Gzip.decompress(data);
+ }
+
LOG.debug("doFetchFullChunkData fid:{} chunkData.length:{}", chunkView.fileId, data.length);
return data;