Skip to content

Commit

Permalink
surround whole switch with one try block instead of two inside the sw…
Browse files Browse the repository at this point in the history
…itch
  • Loading branch information
kelloggm committed Apr 6, 2021
1 parent f023851 commit fa1c0f0
Showing 1 changed file with 15 additions and 20 deletions.
Expand Up @@ -102,28 +102,23 @@ public static StreamMode fromString(String name) {
public static CheckedInputStream getInputStream(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
InputStream is;
switch (getStreamMode(file.getName())) {
case GZIP:
try {
is = new GZIPInputStream(fis);
} catch (IOException e) {
fis.close();
throw e;
}
break;
case SNAPPY:
try {
is = new SnappyInputStream(fis);
} catch (IOException e) {
fis.close();
throw e;
try {
switch (getStreamMode(file.getName())) {
case GZIP:
is = new GZIPInputStream(fis);
break;
case SNAPPY:
is = new SnappyInputStream(fis);
break;
case CHECKED:
default:
is = new BufferedInputStream(fis);
}
break;
case CHECKED:
default:
is = new BufferedInputStream(fis);
return new CheckedInputStream(is, new Adler32());
} catch (IOException e) {
fis.close();
throw e;
}
return new CheckedInputStream(is, new Adler32());
}

/**
Expand Down

0 comments on commit fa1c0f0

Please sign in to comment.