You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/08/25 18:14:20 UTC
[07/13] git commit: Remove unncessary use of streams from
GzipBridgeSerializationDelegate
Remove unncessary use of streams from GzipBridgeSerializationDelegate
Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/c1f102bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/c1f102bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/c1f102bd
Branch: refs/heads/master
Commit: c1f102bd35dd845026f3427caaadbd10b3535f98
Parents: 60799cf
Author: Dane Hammer <da...@cerner.com>
Authored: Thu Jul 31 10:23:21 2014 -0500
Committer: Dane Hammer <da...@cerner.com>
Committed: Thu Jul 31 10:24:28 2014 -0500
----------------------------------------------------------------------
.../GzipBridgeSerializationDelegate.java | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/c1f102bd/storm-core/src/jvm/backtype/storm/serialization/GzipBridgeSerializationDelegate.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/serialization/GzipBridgeSerializationDelegate.java b/storm-core/src/jvm/backtype/storm/serialization/GzipBridgeSerializationDelegate.java
index 89a5fc3..fac07a8 100644
--- a/storm-core/src/jvm/backtype/storm/serialization/GzipBridgeSerializationDelegate.java
+++ b/storm-core/src/jvm/backtype/storm/serialization/GzipBridgeSerializationDelegate.java
@@ -56,25 +56,13 @@ public class GzipBridgeSerializationDelegate implements SerializationDelegate {
}
/**
- * Looks ahead to see if the GZIP magic constant is heading the input stream
+ * Looks ahead to see if the GZIP magic constant is heading {@code bytes}
*/
private boolean isGzipped(byte[] bytes) {
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- PushbackInputStream pis = new PushbackInputStream(bis, 2);
-
- byte[] header = new byte[2];
- try {
- pis.read(header);
- // Push those two bytes back into the stream
- pis.unread(header);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
// Split up GZIP_MAGIC into readable bytes
byte magicFirst = (byte) GZIPInputStream.GZIP_MAGIC;
byte magicSecond =(byte) (GZIPInputStream.GZIP_MAGIC >> 8);
- return (header[0] == magicFirst) && (header[1] == magicSecond);
+ return (bytes[0] == magicFirst) && (bytes[1] == magicSecond);
}
}