Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend IOException #605

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/
package org.apache.commons.compress.archivers;

import java.io.IOException;

/**
* Signals that an Archive exception of some sort has occurred.
*/
public class ArchiveException extends Exception {
public class ArchiveException extends IOException {

/** Serial. */
private static final long serialVersionUID = 2772690708123267100L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static String detect(final InputStream in) throws ArchiveException {
signatureLength = IOUtils.readFully(in, signature);
in.reset();
} catch (final IOException e) {
throw new ArchiveException("IOException while reading signature.", e);
throw new ArchiveException("Failure reading signature.", e);
}

// For now JAR files are detected as ZIP files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/
package org.apache.commons.compress.compressors;

import java.io.IOException;

/**
* Signals that an Compressor exception of some sort has occurred.
*/
public class CompressorException extends Exception {
public class CompressorException extends IOException {

/** Serial. */
private static final long serialVersionUID = -2932901310255908814L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static String detect(final InputStream inputStream, final Set<String> compressor
signatureLength = IOUtils.readFully(inputStream, signature);
inputStream.reset();
} catch (final IOException e) {
throw new CompressorException("IOException while reading signature.", e);
throw new CompressorException("Failed to read signature.", e);
}
if (compressorNames.contains(BZIP2) && BZip2CompressorInputStream.matches(signature, signatureLength)) {
return BZIP2;
Expand Down Expand Up @@ -632,7 +632,7 @@ public CompressorOutputStream<?> createCompressorOutputStream(final String name,
return new ZstdCompressorOutputStream(out);
}
} catch (final IOException e) {
throw new CompressorException("Could not create CompressorOutputStream", e);
throw new CompressorException("Could not create CompressorOutputStream.", e);
}
final CompressorStreamProvider compressorStreamProvider = getCompressorOutputStreamProviders().get(toKey(name));
if (compressorStreamProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void testDetect() throws Exception {

final ArchiveException e3 = assertThrows(ArchiveException.class, () -> ArchiveStreamFactory.detect(new BufferedInputStream(new BrokenInputStream())),
"Expected ArchiveException");
assertEquals("IOException while reading signature.", e3.getMessage());
assertEquals("Failure reading signature.", e3.getMessage());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void testDetect() throws Exception {

final CompressorException ce = assertThrows(CompressorException.class,
() -> CompressorStreamFactory.detect(new BufferedInputStream(new BrokenInputStream())), "Expected IOException");
assertEquals("IOException while reading signature.", ce.getMessage());
assertEquals("Failed to read signature.", ce.getMessage());
}

@ParameterizedTest
Expand Down