Skip to content

Commit

Permalink
errorprone :: EmptyCatch (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
sambish5 committed May 20, 2024
1 parent 85363e0 commit 45abc17
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 35 deletions.
23 changes: 7 additions & 16 deletions src/main/java/emissary/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ public Version() {
* Does not create a Configurator due to logging restrictions on this method.
*/
private void readHardWiredConfigInfo() {
InputStream rstream = null;
try {
// This configurator is not overridable by
// the normal config.pkg or config.dir mechanisms.
// It also cannot call any method in ConfigUtil that
// will end up calling a logger.* method, since we
// are here producing the header for the log file
String rez = Version.class.getName().replace('.', '/') + ConfigUtil.CONFIG_FILE_ENDING;
// This configurator is not overridable by
// the normal config.pkg or config.dir mechanisms.
// It also cannot call any method in ConfigUtil that
// will end up calling a logger.* method, since we
// are here producing the header for the log file
String rez = Version.class.getName().replace('.', '/') + ConfigUtil.CONFIG_FILE_ENDING;
try (InputStream rstream = new ResourceReader().getResourceAsStream(rez)) {
// System.out.println("Reading " + rez);
rstream = new ResourceReader().getResourceAsStream(rez);
if (rstream != null) {
byte[] data = IOUtils.toByteArray(rstream);
String sdata = new String(data);
Expand All @@ -58,13 +56,6 @@ private void readHardWiredConfigInfo() {
}
} catch (IOException iox) {
// System.out.println("Bad read: " + iox);
} finally {
if (rstream != null) {
try {
rstream.close();
} catch (IOException ignore) {
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/test/java/emissary/pickup/PickupQueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void run() {
pq.wait(0);
hitcount++;
} catch (InterruptedException ignored) {
// Ignore
}
}
}
Expand Down
28 changes: 9 additions & 19 deletions src/test/java/emissary/place/ServiceProviderPlaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,15 @@ void testLocOnlyConstructorWithFileConfigDataAndPackage() throws IOException, Em
}

private void runFileConfiguredTest(boolean usePackage, int ctorType) throws IOException, EmissaryException {
Path cfg = null;
OutputStream fos = null;
try {
// Write out the config data to the temp config dir
if (usePackage) {
cfg = Paths.get(CFGDIR, thisPackage.getName() + ".MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
} else {
cfg = Paths.get(CFGDIR, "MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
}
fos = Files.newOutputStream(cfg);
Path cfg;
// Write out the config data to the temp config dir
if (usePackage) {
cfg = Paths.get(CFGDIR, thisPackage.getName() + ".MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
} else {
cfg = Paths.get(CFGDIR, "MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
}

try (OutputStream fos = Files.newOutputStream(cfg)) {
fos.write(configData);

MyFileConfigedTestPlace mtp = null;
Expand Down Expand Up @@ -260,15 +259,6 @@ private void runFileConfiguredTest(boolean usePackage, int ctorType) throws IOEx
// Clean up the tmp config settings
restoreConfig();

assert cfg != null;
Files.deleteIfExists(cfg);

if (fos != null) {
try {
fos.close();
} catch (IOException ignore) {
}
}
Files.deleteIfExists(cfg);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/emissary/test/core/junit5/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ protected void startJetty(int port) throws Exception {
jserver = new EmissaryServer(cmd);
jetty = jserver.startServer();
} catch (Exception ignored) {
// Ignore
}

// Wait for jetty to come up
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
// Ignore
}
referenceServices(port);
}
Expand Down

0 comments on commit 45abc17

Please sign in to comment.