Affects Version/s: 1.2
Fix Version/s: 1.3
java.runtime.name=Java(TM) SE Runtime Environment
This issue may be unrelated to environment
It appears the TarArchiveOutputStream.getBytesWritten()returns zero or invalid value when queried.
In the code sample below, it returns zero, even after an sizeable file was processed.
I've printed it twice, once before closing the output stream, and once after, just for the reference.
It is also demonstrable on multiple processed files.
Within the TarArchiveOutputStream.getBytesWritten() implementation, it appears the call for count(numToWrite) is made after the numToWrite is depleted in the process of actual byte writing. When call for count(numToWrite); is moved up, the returned values for TarArchiveOutputStream.getBytesWritten() are getting equal to the sum of the sizes of processed files. This is much closer to expected value ("Returns the current number of bytes written to this stream.") but still not correct, for that number should include the tar header sizes as well.
At any rate, please find the proposed patch below, merely moving count(numToWrite); up a few lines. This makes TarArchiveOutputStream.getBytesWritten() closer to true value.