Skip to content

Commit

Permalink
use final
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterAlfredLee committed Feb 4, 2021
1 parent 6fed9fb commit 221b2ba
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private void readOldGNUSparse() throws IOException {
* 0 size input streams because they are meaningless.
*/
private void buildSparseInputStreams() throws IOException {
List<InputStream> streams = new ArrayList<>();
final List<InputStream> streams = new ArrayList<>();

final List<TarArchiveStructSparse> sparseHeaders = currEntry.getSparseHeaders();
// sort the sparse headers in case they are written in wrong order
Expand Down Expand Up @@ -368,14 +368,14 @@ public int compare(final TarArchiveStructSparse p, final TarArchiveStructSparse

// only store the input streams with non-zero size
if ((sparseHeader.getOffset() - offset) > 0) {
long sizeOfZeroByteStream = sparseHeader.getOffset() - offset;
final long sizeOfZeroByteStream = sparseHeader.getOffset() - offset;
streams.add(new BoundedInputStream(zeroInputStream, sizeOfZeroByteStream));
numberOfZeroBytesInSparseEntry += sizeOfZeroByteStream;
}

// only store the input streams with non-zero size
if (sparseHeader.getNumbytes() > 0) {
long start =
final long start =
currEntry.getDataOffset() + sparseHeader.getOffset() - numberOfZeroBytesInSparseEntry;
streams.add(new BoundedSeekableByteChannelInputStream(start, sparseHeader.getNumbytes(), archive));
}
Expand Down Expand Up @@ -673,7 +673,7 @@ protected int read(final long pos, final ByteBuffer buf) throws IOException {
}
}

int totalRead = 0;
final int totalRead;
if (entry.isSparse()) {
totalRead = readSparse(entryOffset, buf, buf.limit());
} else {
Expand Down Expand Up @@ -703,8 +703,8 @@ private int readSparse(final long pos, final ByteBuffer buf, final int numToRead
}

final InputStream currentInputStream = entrySparseInputStreams.get(currentSparseInputStreamIndex);
byte[] bufArray = new byte[numToRead];
int readLen = currentInputStream.read(bufArray);
final byte[] bufArray = new byte[numToRead];
final int readLen = currentInputStream.read(bufArray);
if (readLen != -1) {
buf.put(bufArray, 0, readLen);
}
Expand All @@ -725,7 +725,7 @@ private int readSparse(final long pos, final ByteBuffer buf, final int numToRead
// and recursively call read
if (readLen < numToRead) {
currentSparseInputStreamIndex++;
int readLenOfNext = readSparse(pos + readLen, buf, numToRead - readLen);
final int readLenOfNext = readSparse(pos + readLen, buf, numToRead - readLen);
if (readLenOfNext == -1) {
return readLen;
}
Expand All @@ -739,7 +739,7 @@ private int readSparse(final long pos, final ByteBuffer buf, final int numToRead

private int readArchive(final long pos, final ByteBuffer buf) throws IOException {
channel.position(pos);
int read = channel.read(buf);
final int read = channel.read(buf);
buf.flip();
return read;
}
Expand Down

0 comments on commit 221b2ba

Please sign in to comment.