stevedlawrence closed pull request #106: Ensure that buckets with no references 
are released
URL: https://github.com/apache/incubator-daffodil/pull/106
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala 
b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala
index 0b5cfdaa7..fa3477829 100644
--- a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala
+++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala
@@ -372,11 +372,11 @@ class BucketingInputSource(inputStream: 
java.io.InputStream, bucketSize: Int = 1
     Assert.invariant(bucketIndex >= oldestBucketIndex && bucketIndex < 
buckets.length)
     buckets(bucketIndex.toInt).refCount -= 1 
 
-    if (bucketIndex == oldestBucketIndex && 
buckets(bucketIndex.toInt).refCount == 0) {
-      // We just freed the last reference to the oldest bucket. So try to
-      // release as many buckets as possible. Note that this might still not
-      // release anything if the oldest bucket contains the current byte
-      // position.
+    if (buckets(oldestBucketIndex.toInt).refCount == 0) {
+      // We just freed the last reference to the oldest bucket (or the oldest
+      // bucket happened to have no references). So try to release as many
+      // buckets as possible. Note that this might still not release anything
+      // if the oldest bucket contains the current byte position.
       releaseBuckets()
     }
   }
@@ -387,7 +387,7 @@ class BucketingInputSource(inputStream: 
java.io.InputStream, bucketSize: Int = 1
     if (!areDebugging) {
       // Look for old buckets that are no longer referenced by a mark (i.e.
       // refCount is zero), set them to null so they are garbage collected. 
Make
-      // sure not to not remove whatever bucket holds the current byte 
position,
+      // sure not to remove whatever bucket holds the current byte position,
       // even if there are no marks--we need to still read from that bucket.
       val (curBucketIndex, _) = bytePositionToIndicies(curBytePosition0b)
       while (oldestBucketIndex < curBucketIndex && 
buckets(oldestBucketIndex).refCount == 0) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to