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

pmd :: EmptyCatchBlock #1055

Merged
merged 1 commit into from
Feb 7, 2025
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
4 changes: 2 additions & 2 deletions src/main/java/emissary/admin/PlaceStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public static IServiceProviderPlace alreadyExists(final String theLocation) {
final IServiceProviderPlace thePlace = (IServiceProviderPlace) Namespace.lookup(luStr);
logger.debug("{} already running on {}", theLocation, thePlaceHost);
return thePlace;
} catch (NamespaceException nse) {
} catch (NamespaceException ignored) {
// expected when the place doesn't exist
} catch (Throwable t) {
} catch (Throwable ignored) {
// empty catch block
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/command/Banner.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Banner() {
result.append(System.getProperty("line.separator")).append(line);
}
bText = System.getProperty("line.separator") + result.toString();
} catch (IOException e) {
} catch (IOException ignored) {
// will be DEFAULT_TEXT;
}
bannerText = bText;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/emissary/core/FilePickUpPlaceHealthCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ protected Result check() throws Exception {
return Result.unhealthy("Large aggregate file size backed up for FilePickUpPlace = " + aggregateFileSize);
}

} catch (NamespaceException ne) {
} catch (NamespaceException ignored) {
// This gets throw if can't find FilePickUpPlace, assume it is not configured
// and things are healthy
} catch (NoSuchFieldException nsfe) {
} catch (NoSuchFieldException ignored) {
// Possibly thrown by getDeclaredField, assume FilePickUpPlace implementation has changed
} catch (SecurityException se) {
} catch (SecurityException ignored) {
// Possibly thrown by getDeclaredField - would prevent our access to the field
} catch (NullPointerException npe) {
} catch (NullPointerException ignored) {
// A variety of methods throw NPEs
} catch (IllegalArgumentException iae) {
} catch (IllegalArgumentException ignored) {
// Thrown by get()
} catch (IllegalAccessException iae) {
} catch (IllegalAccessException ignored) {
// Also thrown by get()
} catch (ExceptionInInitializerError eiie) {
} catch (ExceptionInInitializerError ignored) {
// Also thrown by get()
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/core/HDMobileAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public String toString() {
try {
sn = this.payloadList.get(0).shortName();
sz = this.payloadList.size();
} catch (Throwable t) {
} catch (Throwable ignored) {
// empty catch block
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/core/IBaseDataObjectHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static void addParentInformationToChild(final IBaseDataObject parentIBase
try {
childIBaseDataObject.putParameter(SessionParser.ORIG_DOC_SIZE_KEY,
Long.toString(childIBaseDataObject.getChannelSize()));
} catch (IOException e) {
} catch (IOException ignored) {
// Do not add the ORIG_DOC_SIZE_KEY parameter.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public BufferedChannelFactoryImpl(final SeekableByteChannelFactory seekableByteC
if (sbc.size() < maxBufferSize) {
b = (int) sbc.size();
}
} catch (IOException e) {
} catch (IOException ignored) {
// Leave b as maxBufferSize.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static long available(final InputStream inputStream) {
for (; inputStream.read() != -1; totalBytesRead++) {
// Do nothing.
}
} catch (final IOException ioe) {
} catch (final IOException ignored) {
// Do nothing.
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/directory/DirectoryEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public boolean isLocal() {
if (!this.lookupAttempted) {
try {
setLocalPlace((IServiceProviderPlace) Namespace.lookup(this.serviceLocation));
} catch (NamespaceException e) {
} catch (NamespaceException ignored) {
// empty catch block
}
logger.debug("NS Lookup for locality on {}{}", this.serviceLocation, this.localPlace == null ? " failed" : " passed");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/directory/EmissaryNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public EmissaryNode(Mode nodeMode) {
final InetAddress local = InetAddress.getLocalHost();
this.nodeName = local.getHostAddress();
this.nodeNameIsDefault = true;
} catch (UnknownHostException ex) {
} catch (UnknownHostException ignored) {
// empty catch block
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/directory/KeyManipulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public static int getExpense(final String key, final int dflt) {
int expense = dflt;
try {
expense = Integer.parseInt(key.substring(pos + 1));
} catch (NumberFormatException e) {
} catch (NumberFormatException ignored) {
// It's optional...
}
return expense;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/kff/ChecksumCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public ChecksumResults digest(final SeekableByteChannelFactory sbcf) {
}

res.setHash(d.getAlgorithm(), d.digest());
} catch (final IOException ioe) {
} catch (final IOException ignored) {
// Ignore
}
}
Expand All @@ -203,7 +203,7 @@ public ChecksumResults digest(final SeekableByteChannelFactory sbcf) {
}

res.setCrc(crc.getValue());
} catch (final IOException ioe) {
} catch (final IOException ignored) {
// Ignore
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/kff/Ssdeep.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public SsContext(final SeekableByteChannelFactory sbcf) {

try (SeekableByteChannel sbc = sbcf.create()) {
expectedInputLength = sbc.size();
} catch (final IOException ioe) {
} catch (final IOException ignored) {
// Ignore
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public SpamSumSignature generateHash(final SeekableByteChannelFactory sbcf) {
while ((bytesRead = is.read(b)) != -1) {
applyBytes(rollState, b, 0, bytesRead);
}
} catch (final IOException e) {
} catch (final IOException ignored) {
// Ignore
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/pool/PayloadLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static boolean launch(Object payload, IServiceProviderPlace place, int er
MoveSpool spool = null;
try {
spool = MoveSpool.lookup();
} catch (NamespaceException spoolex) {
} catch (NamespaceException ignored) {
// empty catch block
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/server/EmissaryServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public boolean isIdle() {
try {
AgentPool pool = AgentPool.lookup();
return pool.getNumActive() == 0;
} catch (NamespaceException ex) {
} catch (NamespaceException ignored) {
// empty catch block
}
return true;
Expand Down Expand Up @@ -535,7 +535,7 @@ public static boolean exists() {
try {
EmissaryServer.lookup();
return true;
} catch (NamespaceException ex) {
} catch (NamespaceException ignored) {
// expected
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/server/api/Shutdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected Response shutdown(HttpServletRequest request, boolean force) {
} else {
EmissaryServer.stopServer();
}
} catch (RuntimeException e) {
} catch (RuntimeException ignored) {
// swallow
}
System.exit(0);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/emissary/util/DateTimeFormatParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static LocalDateTime parseDate(final String dateString, final boolean sup

try {
return Instant.from(DateTimeFormatter.ISO_INSTANT.parse(cleanedDateString)).atZone(zone).toLocalDateTime();
} catch (DateTimeParseException e) {
} catch (DateTimeParseException ignored) {
// ignore
}

Expand All @@ -168,7 +168,7 @@ private static LocalDateTime tryParseWithDateTimeZoneFormats(final String dateSt
ZonedDateTime zdt = ZonedDateTime.parse(dateString, dtf);
zdt = ZonedDateTime.ofInstant(zdt.toInstant(), zone);
return zdt.toLocalDateTime();
} catch (DateTimeParseException e) {
} catch (DateTimeParseException ignored) {
// ignore
}
}
Expand All @@ -187,7 +187,7 @@ private static LocalDateTime tryParseWithDateTimeFormats(final String dateString
for (final DateTimeFormatter dtf : dateTimeFormats) {
try {
return LocalDateTime.parse(dateString, dtf);
} catch (DateTimeParseException e) {
} catch (DateTimeParseException ignored) {
// ignore
}
}
Expand All @@ -207,7 +207,7 @@ private static LocalDateTime tryParseWithDateTimeOffsetFormats(final String date
try {
OffsetDateTime odt = OffsetDateTime.parse(dateString, dtf);
return OffsetDateTime.ofInstant(odt.toInstant(), zone).toLocalDateTime();
} catch (DateTimeParseException e) {
} catch (DateTimeParseException ignored) {
// ignore
}
}
Expand All @@ -227,7 +227,7 @@ private static LocalDateTime tryParseWithDateFormats(final String dateString) {
try {
LocalDate d = LocalDate.parse(dateString, dtf);
return d.atStartOfDay();
} catch (DateTimeParseException e) {
} catch (DateTimeParseException ignored) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void readHardWiredConfigInfo() {
}
}
}
} catch (IOException ignore) {
} catch (IOException ignored) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/io/ReadOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void run() {
}
}
br.close();
} catch (IOException iox) {
} catch (IOException ignored) {
// empty catch block
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/os/OSReleaseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static String getVersionId(Path osReleasePath) {
String versionIdLine = versionIdOptional.get().replace("\"", "");
versionId = versionIdLine.substring(versionIdLine.indexOf("=") + 1);
}
} catch (Exception e) {
} catch (Exception ignored) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/search/ByteMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public byte[] getSValue(String key, int ofs, int limit) {
int length = -1;
try {
length = Integer.parseInt(strLength.trim());
} catch (NumberFormatException e) {
} catch (NumberFormatException ignored) {
// empty catch block
}
if (length <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/search/ByteTokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public String next() {
} else {
token = new String(data, start, currentPosition - start);
}
} catch (UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException ignored) {
// cannot happen...we already verified in constructor
}
return token;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/util/shell/ReadBinaryOutputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ void runImpl() {

try {
IOUtils.copy(inputStream, baos);
} catch (Exception e) {
//
} catch (Exception ignored) {
// ignored.
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/util/shell/ReadOutputBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ void runImpl() {
append("\r\n");
}
}
} catch (Exception ex) {
//
} catch (Exception ignored) {
// ignored.
} finally {
if (this.br != null) {
try {
this.br.close();
} catch (IOException ioxjunk) {
} catch (IOException ignored) {
// empty catch block
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/util/shell/ReadOutputLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ void runImpl() {
// logger.info("{}:{}", this.name, aLine.replace('\n', '~'));
}
} while (aLine != null && !this.finished);
} catch (IOException iox) {
} catch (IOException ignored) {
// ignore
}
try {
this.inputReader.close();
this.bufferedReader.close();
} catch (IOException iox) {
} catch (IOException ignored) {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/web/HtmlEscaper.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static byte[] escapeHtml(final byte[] theData) {
}
escaped = output.toByteArray();

} catch (IOException iox) {
} catch (IOException ignored) {
/* dont care */
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/emissary/config/ServiceConfigGuideTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void testOptImportWhenOptionalFileExistsButHasBadSyntax(@TempDir final Path dir)
assertTrue(Executrix.writeDataToFile(optional, optname));
new ServiceConfigGuide(priname);
fail("File parsing on OPT_IMPORT_FILE must fail when it has bad syntax");
} catch (IOException iox) {
} catch (IOException ignored) {
// expected
} finally {
FileUtils.deleteDirectory(dir.toFile());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/emissary/core/FTestMovingAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() throws Exception {
this.dir2 = startDirectory(9005);
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
} catch (InterruptedException ignored) {
// empty catch block
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/emissary/core/ResourceWatcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void run() {
try (TimedResource tr = ResourceWatcherTest.this.resourceWatcher.starting(this, ResourceWatcherTest.this.place)) {
assert tr != null;
Thread.sleep(rand.nextInt(100));
} catch (InterruptedException ex) {
} catch (InterruptedException ignored) {
// empty catch block
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean enque(WorkBundle paths) {
this.shutDown();
try {
Thread.sleep(100);
} catch (InterruptedException ignore) {
} catch (InterruptedException ignored) {
// empty catch block
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected void demolishServer() {
logger.debug("Stopping {}", obj);
((IServiceProviderPlace) obj).shutDown();
}
} catch (NamespaceException ignore) {
} catch (NamespaceException ignored) {
// empty catch block
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/emissary/util/io/ResourceReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void testResourceLocation() {
assertNotNull(is, "Failed to open " + rez);
try {
is.close();
} catch (IOException ignore) {
} catch (IOException ignored) {
// ignored.
}
}

Expand Down