THRIFT-1041. java: TDeserializer holds onto a reference of the array it reads after...
authorBryan Duxbury <bryanduxbury@apache.org>
Wed, 26 Jan 2011 18:40:30 +0000 (18:40 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Wed, 26 Jan 2011 18:40:30 +0000 (18:40 +0000)
This patch makes sure that after using the bytes passed in, no references are retained.

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1063820 13f79535-47bb-0310-9956-ffa450edef68

lib/java/src/org/apache/thrift/TDeserializer.java
lib/java/src/org/apache/thrift/transport/TMemoryInputTransport.java

index dbefcd8..803d9c6 100644 (file)
@@ -68,6 +68,7 @@ public class TDeserializer {
       trans_.reset(bytes);
       base.read(protocol_);
     } finally {
+      trans_.clear();
       protocol_.reset();
     }
   }
@@ -108,6 +109,7 @@ public class TDeserializer {
     } catch (Exception e) {
       throw new TException(e);
     } finally {
+      trans_.clear();
       protocol_.reset();
     }
   }
@@ -228,6 +230,7 @@ public class TDeserializer {
     } catch (Exception e) {
       throw new TException(e);
     } finally {
+      trans_.clear();
       protocol_.reset();
     }
   }
@@ -284,6 +287,7 @@ public class TDeserializer {
     } catch (Exception e) {
       throw new TException(e);
     } finally {
+      trans_.clear();
       protocol_.reset();
     }
   }
index 13b5f83..2530dcc 100644 (file)
@@ -45,6 +45,10 @@ public final class TMemoryInputTransport extends TTransport {
     endPos_ = offset + length;
   }
 
+  public void clear() {
+    buf_ = null;
+  }
+
   @Override
   public void close() {}