diff --git a/cat-core/src/main/java/com/dianping/cat/report/service/BaseRemoteModelService.java b/cat-core/src/main/java/com/dianping/cat/report/service/BaseRemoteModelService.java index a3983d78b9..ab5b2bbe6b 100755 --- a/cat-core/src/main/java/com/dianping/cat/report/service/BaseRemoteModelService.java +++ b/cat-core/src/main/java/com/dianping/cat/report/service/BaseRemoteModelService.java @@ -91,9 +91,8 @@ public ModelResponse invoke(ModelRequest request) { t.addData(url.toString()); - InputStream in = Urls.forIO().connectTimeout(1000).readTimeout(10000).openStream(url.toExternalForm()); - GZIPInputStream gzip = new GZIPInputStream(in); - String xml = Files.forIO().readFrom(gzip, "utf-8"); + InputStream in = Urls.forIO().connectTimeout(1000).readTimeout(10000).withGzip().openStream(url.toExternalForm()); + String xml = Files.forIO().readFrom(in, "utf-8"); int len = xml == null ? 0 : xml.length(); diff --git a/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/LocalMessageService.java b/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/LocalMessageService.java index 38aca2f6ae..7d233fcc64 100644 --- a/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/LocalMessageService.java +++ b/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/LocalMessageService.java @@ -88,7 +88,7 @@ private String buildNewReport(ModelRequest request, ModelPeriod period, String d MessageTree tree = null; if (buf != null) { - tree = CodecHandler.decode(buf); + tree = CodecHandler.decode(changeBuf(buf)); } if (tree == null) { @@ -101,7 +101,7 @@ private String buildNewReport(ModelRequest request, ModelPeriod period, String d ByteBuf data = bucket.get(id); if (data != null) { - tree = CodecHandler.decode(data); + tree = CodecHandler.decode(changeBuf(data)); } } } @@ -126,6 +126,17 @@ private String buildNewReport(ModelRequest request, ModelPeriod period, String d return null; } + private ByteBuf changeBuf(ByteBuf data) { + data.markReaderIndex(); + int length = data.readInt(); + data.resetReaderIndex(); + ByteBuf readBytes = data.readBytes(length + 4); + + readBytes.markReaderIndex(); + readBytes.readInt(); + return readBytes; + } + public String buildOldReport(ModelRequest request, ModelPeriod period, String domain, ApiPayload payload) throws Exception { String messageId = payload.getMessageId(); diff --git a/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/RemoteLogViewService.java b/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/RemoteLogViewService.java index 995a066d89..ca9d74ca67 100755 --- a/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/RemoteLogViewService.java +++ b/cat-home/src/main/java/com/dianping/cat/report/page/logview/service/RemoteLogViewService.java @@ -59,9 +59,8 @@ public ModelResponse invoke(ModelRequest request) { t.addData(url.toString()); - InputStream in = Urls.forIO().connectTimeout(1000).readTimeout(5000).openStream(url.toExternalForm()); - GZIPInputStream gzip = new GZIPInputStream(in); - String xml = Files.forIO().readFrom(gzip, "utf-8"); + InputStream in = Urls.forIO().connectTimeout(1000).readTimeout(5000).withGzip().openStream(url.toExternalForm()); + String xml = Files.forIO().readFrom(in, "utf-8"); int len = xml == null ? 0 : xml.length();