Repository: incubator-nifi
Updated Branches:
  refs/heads/develop 548f6d083 -> 531136db9


NIFI-230: Fixed bug in calculating how much data has been written to a 
ContentClaim


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/c4d186bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/c4d186bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/c4d186bd

Branch: refs/heads/develop
Commit: c4d186bdd997f3f697bf6c9d3ed8a09bbe970e8b
Parents: b7b42c7
Author: Mark Payne <[email protected]>
Authored: Thu Jun 18 11:30:04 2015 -0400
Committer: Mark Payne <[email protected]>
Committed: Thu Jun 18 11:30:04 2015 -0400

----------------------------------------------------------------------
 .../repository/VolatileContentRepository.java   | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/c4d186bd/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
----------------------------------------------------------------------
diff --git 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
index 5971865..e35a63c 100644
--- 
a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
+++ 
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/VolatileContentRepository.java
@@ -419,7 +419,7 @@ public class VolatileContentRepository implements 
ContentRepository {
         }
 
         final ContentClaim backupClaim = getBackupClaim(claim);
-        return (backupClaim == null) ? getContent(claim).getSize() : 
getBackupRepository().size(claim);
+        return backupClaim == null ? getContent(claim).getSize() : 
getBackupRepository().size(claim);
     }
 
     @Override
@@ -429,13 +429,13 @@ public class VolatileContentRepository implements 
ContentRepository {
         }
 
         final ContentClaim backupClaim = getBackupClaim(claim);
-        return (backupClaim == null) ? getContent(claim).read() : 
getBackupRepository().read(backupClaim);
+        return backupClaim == null ? getContent(claim).read() : 
getBackupRepository().read(backupClaim);
     }
 
     @Override
     public OutputStream write(final ContentClaim claim) throws IOException {
         final ContentClaim backupClaim = getBackupClaim(claim);
-        return (backupClaim == null) ? getContent(claim).write() : 
getBackupRepository().write(backupClaim);
+        return backupClaim == null ? getContent(claim).write() : 
getBackupRepository().write(backupClaim);
     }
 
     @Override
@@ -481,8 +481,13 @@ public class VolatileContentRepository implements 
ContentRepository {
                 @Override
                 public void write(int b) throws IOException {
                     try {
+                        final long bufferLengthBefore = getBufferLength();
                         super.write(b);
-                        repoSizeCounter.incrementAndGet();
+                        final long bufferLengthAfter = getBufferLength();
+                        final long bufferSpaceAdded = bufferLengthAfter - 
bufferLengthBefore;
+                        if (bufferSpaceAdded > 0) {
+                            repoSizeCounter.addAndGet(bufferSpaceAdded);
+                        }
                     } catch (final IOException e) {
                         final byte[] buff = new byte[1];
                         buff[0] = (byte) (b & 0xFF);
@@ -498,8 +503,13 @@ public class VolatileContentRepository implements 
ContentRepository {
                 @Override
                 public void write(byte[] b, int off, int len) throws 
IOException {
                     try {
+                        final long bufferLengthBefore = getBufferLength();
                         super.write(b, off, len);
-                        repoSizeCounter.addAndGet(len);
+                        final long bufferLengthAfter = getBufferLength();
+                        final long bufferSpaceAdded = bufferLengthAfter - 
bufferLengthBefore;
+                        if (bufferSpaceAdded > 0) {
+                            repoSizeCounter.addAndGet(bufferSpaceAdded);
+                        }
                     } catch (final IOException e) {
                         redirect(b, off, len);
                     }

Reply via email to