Skip to content

Commit 4aaa10a

Browse files
slp091020Shane Parris
andauthored
Code analysis cleanup and #435 mistake? (#458)
* Fixup #435: Add null check when getting and applying Windows file attributes * Clean up raw types Co-authored-by: Shane Parris <s@zd.is>
1 parent 5013235 commit 4aaa10a

10 files changed

Lines changed: 18 additions & 18 deletions

src/main/java/net/lingala/zip4j/io/inputstream/DecompressedInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
abstract class DecompressedInputStream extends InputStream {
88

9-
private CipherInputStream cipherInputStream;
9+
private CipherInputStream<?> cipherInputStream;
1010
protected byte[] oneByteBuffer = new byte[1];
1111

12-
public DecompressedInputStream(CipherInputStream cipherInputStream) {
12+
public DecompressedInputStream(CipherInputStream<?> cipherInputStream) {
1313
this.cipherInputStream = cipherInputStream;
1414
}
1515

src/main/java/net/lingala/zip4j/io/inputstream/InflaterInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class InflaterInputStream extends DecompressedInputStream {
1414
private byte[] singleByteBuffer = new byte[1];
1515
private int len;
1616

17-
public InflaterInputStream(CipherInputStream cipherInputStream, int bufferSize) {
17+
public InflaterInputStream(CipherInputStream<?> cipherInputStream, int bufferSize) {
1818
super(cipherInputStream);
1919
this.inflater = new Inflater(true);
2020
buff = new byte[bufferSize];

src/main/java/net/lingala/zip4j/io/inputstream/NoCipherInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
import java.io.IOException;
77

8-
class NoCipherInputStream extends CipherInputStream {
8+
class NoCipherInputStream extends CipherInputStream<NoCipherInputStream.NoDecrypter> {
99

1010
public NoCipherInputStream(ZipEntryInputStream zipEntryInputStream, LocalFileHeader localFileHeader,
1111
char[] password, int bufferSize) throws IOException {
1212
super(zipEntryInputStream, localFileHeader, password, bufferSize, true);
1313
}
1414

1515
@Override
16-
protected Decrypter initializeDecrypter(LocalFileHeader localFileHeader, char[] password, boolean useUtf8ForPassword) {
16+
protected NoDecrypter initializeDecrypter(LocalFileHeader localFileHeader, char[] password, boolean useUtf8ForPassword) {
1717
return new NoDecrypter();
1818
}
1919

src/main/java/net/lingala/zip4j/io/inputstream/StoreInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class StoreInputStream extends DecompressedInputStream {
44

5-
public StoreInputStream(CipherInputStream cipherInputStream) {
5+
public StoreInputStream(CipherInputStream<?> cipherInputStream) {
66
super(cipherInputStream);
77
}
88
}

src/main/java/net/lingala/zip4j/io/inputstream/ZipInputStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ private void endOfCompressedDataReached() throws IOException {
244244

245245
private DecompressedInputStream initializeEntryInputStream(LocalFileHeader localFileHeader) throws IOException {
246246
ZipEntryInputStream zipEntryInputStream = new ZipEntryInputStream(inputStream, getCompressedSize(localFileHeader));
247-
CipherInputStream cipherInputStream = initializeCipherInputStream(zipEntryInputStream, localFileHeader);
247+
CipherInputStream<?> cipherInputStream = initializeCipherInputStream(zipEntryInputStream, localFileHeader);
248248
return initializeDecompressorForThisEntry(cipherInputStream, localFileHeader);
249249
}
250250

251-
private CipherInputStream initializeCipherInputStream(ZipEntryInputStream zipEntryInputStream,
251+
private CipherInputStream<?> initializeCipherInputStream(ZipEntryInputStream zipEntryInputStream,
252252
LocalFileHeader localFileHeader) throws IOException {
253253
if (!localFileHeader.isEncrypted()) {
254254
return new NoCipherInputStream(zipEntryInputStream, localFileHeader, password, zip4jConfig.getBufferSize());
@@ -266,7 +266,7 @@ private CipherInputStream initializeCipherInputStream(ZipEntryInputStream zipEnt
266266
}
267267
}
268268

269-
private DecompressedInputStream initializeDecompressorForThisEntry(CipherInputStream cipherInputStream,
269+
private DecompressedInputStream initializeDecompressorForThisEntry(CipherInputStream<?> cipherInputStream,
270270
LocalFileHeader localFileHeader) throws ZipException {
271271
CompressionMethod compressionMethod = getCompressionMethod(localFileHeader);
272272

src/main/java/net/lingala/zip4j/io/outputstream/CompressedOutputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
abstract class CompressedOutputStream extends OutputStream {
77

8-
private CipherOutputStream cipherOutputStream;
8+
private CipherOutputStream<?> cipherOutputStream;
99

10-
public CompressedOutputStream(CipherOutputStream cipherOutputStream) {
10+
public CompressedOutputStream(CipherOutputStream<?> cipherOutputStream) {
1111
this.cipherOutputStream = cipherOutputStream;
1212
}
1313

src/main/java/net/lingala/zip4j/io/outputstream/DeflaterOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DeflaterOutputStream extends CompressedOutputStream {
2626
private byte[] buff;
2727
protected Deflater deflater;
2828

29-
public DeflaterOutputStream(CipherOutputStream cipherOutputStream, CompressionLevel compressionLevel, int bufferSize) {
29+
public DeflaterOutputStream(CipherOutputStream<?> cipherOutputStream, CompressionLevel compressionLevel, int bufferSize) {
3030
super(cipherOutputStream);
3131
deflater = new Deflater(compressionLevel.getLevel(), true);
3232
buff = new byte[bufferSize];

src/main/java/net/lingala/zip4j/io/outputstream/StoreOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class StoreOutputStream extends CompressedOutputStream {
44

5-
public StoreOutputStream(CipherOutputStream cipherOutputStream) {
5+
public StoreOutputStream(CipherOutputStream<?> cipherOutputStream) {
66
super(cipherOutputStream);
77
}
88

src/main/java/net/lingala/zip4j/io/outputstream/ZipOutputStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ private void writeSplitZipHeaderIfApplicable() throws IOException {
190190

191191
private CompressedOutputStream initializeCompressedOutputStream(ZipParameters zipParameters) throws IOException {
192192
ZipEntryOutputStream zipEntryOutputStream = new ZipEntryOutputStream(countingOutputStream);
193-
CipherOutputStream cipherOutputStream = initializeCipherOutputStream(zipEntryOutputStream, zipParameters);
193+
CipherOutputStream<?> cipherOutputStream = initializeCipherOutputStream(zipEntryOutputStream, zipParameters);
194194
return initializeCompressedOutputStream(cipherOutputStream, zipParameters);
195195
}
196196

197-
private CipherOutputStream initializeCipherOutputStream(ZipEntryOutputStream zipEntryOutputStream,
197+
private CipherOutputStream<?> initializeCipherOutputStream(ZipEntryOutputStream zipEntryOutputStream,
198198
ZipParameters zipParameters) throws IOException {
199199
if (!zipParameters.isEncryptFiles()) {
200200
return new NoCipherOutputStream(zipEntryOutputStream, zipParameters, null);
@@ -215,7 +215,7 @@ private CipherOutputStream initializeCipherOutputStream(ZipEntryOutputStream zip
215215
}
216216
}
217217

218-
private CompressedOutputStream initializeCompressedOutputStream(CipherOutputStream cipherOutputStream,
218+
private CompressedOutputStream initializeCompressedOutputStream(CipherOutputStream<?> cipherOutputStream,
219219
ZipParameters zipParameters) {
220220
if (zipParameters.getCompressionMethod() == CompressionMethod.DEFLATE) {
221221
return new DeflaterOutputStream(cipherOutputStream, zipParameters.getCompressionLevel(), zip4jConfig.getBufferSize());

src/main/java/net/lingala/zip4j/util/FileUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,11 @@ private static void applyWindowsFileAttributes(Path file, byte[] fileAttributes)
469469

470470
DosFileAttributeView fileAttributeView = Files.getFileAttributeView(file, DosFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
471471

472-
//IntelliJ complains that fileAttributes can never be null. But apparently it can.
472+
//IntelliJ complains that fileAttributeView can never be null. But apparently it can.
473473
//See https://github.com/srikanth-lingala/zip4j/issues/435
474474
//Even the javadoc of Files.getFileAttributeView says it can be null
475475
//noinspection ConstantConditions
476-
if (fileAttributes == null) {
476+
if (fileAttributeView == null) {
477477
return;
478478
}
479479

0 commit comments

Comments
 (0)