mirror of https://github.com/apache/nifi.git
NIFI-230: Fixed bug in calculating how much data has been written to a ContentClaim
This commit is contained in:
parent
b7b42c7423
commit
c4d186bdd9
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue