From 2c50a228bbde8098b98a314f3e8b1767db89ef92 Mon Sep 17 00:00:00 2001 From: dev-mlb <19797865+dev-mlb@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:43:04 -0400 Subject: [PATCH] errorprone :: CatchingUnchecked --- src/main/java/emissary/Emissary.java | 1 + .../java/emissary/client/EmissaryResponse.java | 15 +++++---------- .../java/emissary/command/MonitorCommand.java | 2 +- .../java/emissary/command/TopologyCommand.java | 8 ++------ .../java/emissary/config/ServiceConfigGuide.java | 2 +- src/main/java/emissary/core/MobileAgent.java | 4 ++-- src/main/java/emissary/core/TimedResource.java | 2 +- .../java/emissary/core/sentinel/Sentinel.java | 2 +- .../java/emissary/directory/DirectoryPlace.java | 6 +++--- .../java/emissary/directory/HeartbeatManager.java | 4 ++-- src/main/java/emissary/jni/JNI.java | 9 +++++---- src/main/java/emissary/kff/KffChainLoader.java | 2 +- src/main/java/emissary/output/DropOffPlace.java | 6 +++--- src/main/java/emissary/parser/ParserFactory.java | 4 ++-- src/main/java/emissary/pickup/PickUpSpace.java | 2 +- src/main/java/emissary/pickup/QueServer.java | 4 ++-- .../java/emissary/place/CoordinationPlace.java | 2 +- .../emissary/place/MultiFileUnixCommandPlace.java | 5 +---- .../java/emissary/place/ServiceProviderPlace.java | 6 +++--- src/main/java/emissary/pool/AgentPool.java | 2 +- src/main/java/emissary/pool/MoveSpool.java | 2 +- src/main/java/emissary/pool/PayloadLauncher.java | 1 + src/main/java/emissary/roll/RollManager.java | 2 +- src/main/java/emissary/server/api/Shutdown.java | 4 ++-- .../server/mvc/internal/RollOutputsAction.java | 5 +++-- .../emissary/transform/decode/HtmlEscape.java | 1 + src/main/java/emissary/util/CharsetUtil.java | 2 +- .../java/emissary/util/DateTimeFormatParser.java | 4 ++-- .../emissary/util/DateTimeFormatParserLegacy.java | 2 +- src/main/java/emissary/util/DisposeHelper.java | 2 +- src/main/java/emissary/util/UnixFile.java | 10 +++------- 31 files changed, 56 insertions(+), 67 deletions(-) diff --git a/src/main/java/emissary/Emissary.java b/src/main/java/emissary/Emissary.java index 02fe3e3132..4b2a567d05 100644 --- a/src/main/java/emissary/Emissary.java +++ b/src/main/java/emissary/Emissary.java @@ -88,6 +88,7 @@ protected Emissary(Map cmds) { } } + @SuppressWarnings("CatchingUnchecked") protected void execute(String[] args) { reconfigureLogHook(); // so we can capture everything for test, like the verbose output String shouldSetVerbose = System.getProperty("set.picocli.debug"); diff --git a/src/main/java/emissary/client/EmissaryResponse.java b/src/main/java/emissary/client/EmissaryResponse.java index 7ecf97ac7e..8c9312fdf1 100644 --- a/src/main/java/emissary/client/EmissaryResponse.java +++ b/src/main/java/emissary/client/EmissaryResponse.java @@ -79,17 +79,12 @@ public String getContentString() { if (content == null) { return null; } - try { - if (status == HttpStatus.SC_OK) { - return content.toString(); - } else { - return "Bad request -> status: " + status + " message: " + content; - } - } catch (Exception e) { - logger.error("Error getting string content", e); - return e.getMessage(); - } + if (status == HttpStatus.SC_OK) { + return content.toString(); + } else { + return "Bad request -> status: " + status + " message: " + content; + } } public T getContent(Class mapper) { diff --git a/src/main/java/emissary/command/MonitorCommand.java b/src/main/java/emissary/command/MonitorCommand.java index a5ed698f13..bc66b70bbd 100644 --- a/src/main/java/emissary/command/MonitorCommand.java +++ b/src/main/java/emissary/command/MonitorCommand.java @@ -85,7 +85,7 @@ private void sendClusterRequests(final EmissaryClient client, final T entity) th synchronized (lock) { entity.append(response); } - } catch (Exception e) { + } catch (RuntimeException e) { LOG.error("Problem hitting agents endpoint: {}\n{}", hostAndPort, e.getMessage()); synchronized (lock) { entity.addError(e.getMessage()); diff --git a/src/main/java/emissary/command/TopologyCommand.java b/src/main/java/emissary/command/TopologyCommand.java index 14e12889c4..7ac8f5a7a7 100644 --- a/src/main/java/emissary/command/TopologyCommand.java +++ b/src/main/java/emissary/command/TopologyCommand.java @@ -34,12 +34,8 @@ public void run(CommandLine c) { String endpoint = getScheme() + "://" + getHost() + ":" + getPort() + "/api/cluster/peers"; LOG.info("Hitting " + endpoint); EmissaryClient client = new EmissaryClient(); - try { - PeersResponseEntity entity = client.send(new HttpGet(endpoint)).getContent(PeersResponseEntity.class); - entity.dumpToConsole(); - } catch (Exception e) { - LOG.error("Problem hitting peers endpoint: " + e.getMessage()); - } + PeersResponseEntity entity = client.send(new HttpGet(endpoint)).getContent(PeersResponseEntity.class); + entity.dumpToConsole(); } diff --git a/src/main/java/emissary/config/ServiceConfigGuide.java b/src/main/java/emissary/config/ServiceConfigGuide.java index d50ad2b2e5..4c3435b1f7 100755 --- a/src/main/java/emissary/config/ServiceConfigGuide.java +++ b/src/main/java/emissary/config/ServiceConfigGuide.java @@ -411,7 +411,7 @@ protected String substituteUtfChars(final String s, final String filename, final final int digit = Integer.parseInt(s.substring(i + 2, epos), 16); sb.appendCodePoint(digit); i = epos - 1; - } catch (Exception ex) { + } catch (RuntimeException ex) { throw new IOException("Unable to convert characters in " + s + ", from filename=" + filename + " line " + lnum, ex); } } diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 11167d3201..e03f779b1b 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -188,7 +188,7 @@ public void killAgentAsync() { try { this.thread.setPriority(Thread.MIN_PRIORITY); this.thread.interrupt(); - } catch (Exception ignored) { + } catch (RuntimeException ignored) { // empty catch block } } @@ -619,7 +619,7 @@ protected DirectoryEntry nextKeyFromDirectory(final String dataId, final IServic logger.debug("Added {} new key entries from the directory for {}", entries.size(), dataId); } - } catch (Exception e) { + } catch (RuntimeException e) { logger.warn("cannot get key, I was working on: {}", payloadArg.shortName(), e); // Returning instead of throwing will allow // the next form to be tried. diff --git a/src/main/java/emissary/core/TimedResource.java b/src/main/java/emissary/core/TimedResource.java index 9853231549..b789e3210a 100644 --- a/src/main/java/emissary/core/TimedResource.java +++ b/src/main/java/emissary/core/TimedResource.java @@ -72,7 +72,7 @@ void interruptAgent() { LOG.debug("Found agent that needs interrupting {} in place {}", agent.getName(), placeName); agent.interrupt(); } - } catch (Exception e) { + } catch (RuntimeException e) { LOG.error("Unable to interrupt agent {}: {}", agent.getName(), e.getMessage(), e); } finally { lock.unlock(); diff --git a/src/main/java/emissary/core/sentinel/Sentinel.java b/src/main/java/emissary/core/sentinel/Sentinel.java index 7c3d02dc32..c4f6f865eb 100644 --- a/src/main/java/emissary/core/sentinel/Sentinel.java +++ b/src/main/java/emissary/core/sentinel/Sentinel.java @@ -151,7 +151,7 @@ protected void init() { } else { logger.debug("Sentinel protocol disabled {}", protocol); } - } catch (Exception e) { + } catch (RuntimeException e) { logger.warn("Unable to configure Sentinel Protocol[{}]: {}", protocolConfig, e.getMessage()); } } diff --git a/src/main/java/emissary/directory/DirectoryPlace.java b/src/main/java/emissary/directory/DirectoryPlace.java index be5678c468..225b19c161 100755 --- a/src/main/java/emissary/directory/DirectoryPlace.java +++ b/src/main/java/emissary/directory/DirectoryPlace.java @@ -804,7 +804,7 @@ protected void sendFailMessage(final DirectoryEntry directory, final String fail try { new DirectoryAdapter().outboundFailDirectory(directory.getKey(), failKey, permanent); - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.error("Problem talking to directory {} to fail {}", directory.getKey(), failKey, ex); } } @@ -931,7 +931,7 @@ protected void registerWith(final DirectoryEntry dir, final List try { new DirectoryAdapter().outboundAddPlaces(dir.getKey(), entryList, propagating); logger.debug("registration succeeded"); - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.warn("DirectoryPlace.registerWith: Problem talking to directory {} to add {} entries", dir.getKey(), entryList.size(), ex); } } @@ -1269,7 +1269,7 @@ protected void deregisterFrom(final DirectoryEntry dir, final List keys, try { // Follow the logic to irdRemovePlaces on the remote side new DirectoryAdapter().outboundRemovePlaces(dir.getKey(), keys, propagating); - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.error("DirectoryPlace.deregisterFrom: " + "Problem talking to directory " + dir.getKey() + " to deregister keys", ex); } } diff --git a/src/main/java/emissary/directory/HeartbeatManager.java b/src/main/java/emissary/directory/HeartbeatManager.java index f9e7cf80d8..2c42cdea5f 100755 --- a/src/main/java/emissary/directory/HeartbeatManager.java +++ b/src/main/java/emissary/directory/HeartbeatManager.java @@ -319,7 +319,7 @@ public void run() { heartbeat(dir); } logger.debug("Ending the HeartbeatTask run method"); - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Unexpected problem in heartbeat timer", e); } } @@ -345,7 +345,7 @@ public final boolean heartbeat(final String key) { healthReport(key, false, response.getContentString()); isup = false; } - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Cannot perform heartbeat", e); healthReport(key, false, e.getMessage()); isup = false; diff --git a/src/main/java/emissary/jni/JNI.java b/src/main/java/emissary/jni/JNI.java index 684f2a4b10..38fe7d6afd 100755 --- a/src/main/java/emissary/jni/JNI.java +++ b/src/main/java/emissary/jni/JNI.java @@ -20,6 +20,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.Serializable; +import java.rmi.RemoteException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -374,7 +375,7 @@ public byte[] returnFile(final String filename, final String[] errmsg) { // We have a repository of some sort, try using it return returnFile(filename, errmsg, repositoryKey); - } catch (Exception ve) { + } catch (RuntimeException ve) { errmsg[0] = "JNI.returnFile: " + ve; return null; } @@ -396,7 +397,7 @@ public byte[] returnFile(final String filename, final String[] errmsg, final Str final String look = repositoryAddrString.substring(repositoryAddrString.indexOf("//")); repositoryProxy = (IJniRepositoryPlace) Namespace.lookup(look); - } catch (Exception e) { + } catch (NamespaceException | RuntimeException e) { errmsg[0] = "JNI.returnFile: " + e; return null; } @@ -406,7 +407,7 @@ public byte[] returnFile(final String filename, final String[] errmsg, final Str final byte[] libContents; try { libContents = repositoryProxy.nativeLibraryDeliver(filename); - } catch (Exception e) { + } catch (RemoteException | RuntimeException e) { errmsg[0] = "Error calling nativeLibraryDeliver: " + e; return null; } @@ -452,7 +453,7 @@ public long lastModified(final String filename, final String[] errmsg, final Str try { stamp = repositoryProxy.lastModified(filename); - } catch (Exception e) { + } catch (RuntimeException e) { errmsg[0] = "Error calling lastModified: " + e; } diff --git a/src/main/java/emissary/kff/KffChainLoader.java b/src/main/java/emissary/kff/KffChainLoader.java index 88f3d4eed5..9c7a971f23 100755 --- a/src/main/java/emissary/kff/KffChainLoader.java +++ b/src/main/java/emissary/kff/KffChainLoader.java @@ -88,7 +88,7 @@ private static int loadFrom(KffChain chain, Map m, FilterType fi KffFilter k; try { k = (KffFilter) Factory.create(clazz, name, key, filterType); - } catch (Exception x) { + } catch (RuntimeException x) { logger.warn("Cannot create KffFilter, using default", x); k = new KffFile(name, key, filterType); } diff --git a/src/main/java/emissary/output/DropOffPlace.java b/src/main/java/emissary/output/DropOffPlace.java index c92daec2fd..4a4bc8ebf9 100755 --- a/src/main/java/emissary/output/DropOffPlace.java +++ b/src/main/java/emissary/output/DropOffPlace.java @@ -130,7 +130,7 @@ protected void initializeFilters(final List filterClasses) { } else { logger.error("Misconfigured filter {} is not an IDropOffFilter instance, ignoring it", clazz); } - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.error("Unable to create or initialize {}", clazz, ex); } } @@ -199,7 +199,7 @@ public List agentProcessHeavyDuty(final List p // Process the payload item with HDcontext=true processData(d, true); - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Place.process threw:", e); d.addProcessingError("agentProcessHD(" + myKey + "): " + e); @@ -435,7 +435,7 @@ protected void runOutputFilters(final Object target, final Map f filterStatus = IDropOffFilter.STATUS_SUCCESS; } logger.debug("Filter {} took {}s - {}", filter.getFilterName(), ((System.currentTimeMillis() - start) / 1000.0), filterStatus); - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Filter {} failed", filter.getFilterName(), e); } diff --git a/src/main/java/emissary/parser/ParserFactory.java b/src/main/java/emissary/parser/ParserFactory.java index a9a153dac4..4ea8feb501 100755 --- a/src/main/java/emissary/parser/ParserFactory.java +++ b/src/main/java/emissary/parser/ParserFactory.java @@ -176,7 +176,7 @@ protected SessionParser makeSessionParserClass(@Nullable String clazz, Object... try { sp = (SessionParser) Factory.create(clazz, args); - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Unable to instantiate {}", clazz, e); } @@ -190,7 +190,7 @@ protected void makeIdEngine(String clazz) { try { DataIdentifier d = (DataIdentifier) Factory.create(clazz); idEngine = d; - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.warn("Cannot make data identifier from " + clazz, ex); } } diff --git a/src/main/java/emissary/pickup/PickUpSpace.java b/src/main/java/emissary/pickup/PickUpSpace.java index 00d94a1314..599075acc0 100755 --- a/src/main/java/emissary/pickup/PickUpSpace.java +++ b/src/main/java/emissary/pickup/PickUpSpace.java @@ -155,7 +155,7 @@ public boolean take() { WorkBundle path = null; try { path = tpa.outboundWorkSpaceTake(openSpaceName, myKey); - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.error("Failed to take work from " + openSpaceName, ex); } diff --git a/src/main/java/emissary/pickup/QueServer.java b/src/main/java/emissary/pickup/QueServer.java index e3243e714b..4bb0df6b37 100755 --- a/src/main/java/emissary/pickup/QueServer.java +++ b/src/main/java/emissary/pickup/QueServer.java @@ -77,7 +77,7 @@ public void run() { // Process something on the queue try { checkQue(); - } catch (Exception e) { + } catch (RuntimeException e) { logger.warn("Exception in checkQue():" + e, e); } @@ -131,7 +131,7 @@ public void checkQue() { boolean status = processQueueItem(paths); logger.debug("Initiating bundle completed msg for {}, status={}", paths.getBundleId(), status); space.bundleCompleted(paths.getBundleId(), status); - } catch (Exception e) { + } catch (RuntimeException e) { StringBuilder fnb = new StringBuilder(); // Report filenames on error for (Iterator i = paths.getFileNameIterator(); i.hasNext();) { diff --git a/src/main/java/emissary/place/CoordinationPlace.java b/src/main/java/emissary/place/CoordinationPlace.java index bd6c18310f..9342cb5db4 100755 --- a/src/main/java/emissary/place/CoordinationPlace.java +++ b/src/main/java/emissary/place/CoordinationPlace.java @@ -135,7 +135,7 @@ protected void configurePlace() { failedCoordPlaceCreation.add(s + " in " + configG.findStringEntry("PLACE_NAME")); logger.error("Place does not exist and cannot be created: {}", s); } - } catch (Exception e) { + } catch (RuntimeException e) { failedCoordPlaceCreation.add(s + " in " + configG.findStringEntry("PLACE_NAME")); logger.error("Place does not exist and cannot be created: {}", s, e); } diff --git a/src/main/java/emissary/place/MultiFileUnixCommandPlace.java b/src/main/java/emissary/place/MultiFileUnixCommandPlace.java index 89ba7ad0fc..9075265752 100755 --- a/src/main/java/emissary/place/MultiFileUnixCommandPlace.java +++ b/src/main/java/emissary/place/MultiFileUnixCommandPlace.java @@ -668,11 +668,8 @@ protected List processData(@Nullable IBaseDataObject tData, int if (files != null && !files.isEmpty()) { sprouts = sproutResults(tData, files, f.getParent(), parentData); } - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.error("Problem in command execution", ex); - if (ex instanceof InterruptedException) { - throw new ResourceException(ex); // framework notification to stop - } } finally { // Delete the temporary directory and all of its contents. if (f != null) { diff --git a/src/main/java/emissary/place/ServiceProviderPlace.java b/src/main/java/emissary/place/ServiceProviderPlace.java index 06ed7d45ca..f12b0f2613 100755 --- a/src/main/java/emissary/place/ServiceProviderPlace.java +++ b/src/main/java/emissary/place/ServiceProviderPlace.java @@ -529,7 +529,7 @@ public void agentProcessCall(IBaseDataObject payload) throws ResourceException { rehash(payload); } catch (ResourceException r) { throw r; - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Place.process exception", e); } } @@ -898,7 +898,7 @@ protected void registerWithDirectory(List keylist) { logger.debug("Registering my {} keys {}", keylist.size(), keylist); localDirPlace.addPlaces(keylist); } - } catch (Exception e) { + } catch (RuntimeException e) { logger.warn("Register ERROR for keys {}", keylist, e); } } @@ -921,7 +921,7 @@ protected void deregisterFromDirectory(List keys) { logger.debug("Deregistering my {} proxies {}", keys.size(), keys); localDirPlace.removePlaces(keys); } - } catch (Exception e) { + } catch (RuntimeException e) { logger.warn("Deregister ERROR keys={}", keys, e); } } diff --git a/src/main/java/emissary/pool/AgentPool.java b/src/main/java/emissary/pool/AgentPool.java index 679b1bf1fb..403474a910 100755 --- a/src/main/java/emissary/pool/AgentPool.java +++ b/src/main/java/emissary/pool/AgentPool.java @@ -233,7 +233,7 @@ protected void emptyPool() { try { // destroys the object, needed to decrement the numIdle returnAgent(a); - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("Error trying to returnAgent: {}", a.getName(), e); } } diff --git a/src/main/java/emissary/pool/MoveSpool.java b/src/main/java/emissary/pool/MoveSpool.java index b8a5a3b7d3..b22a384d4c 100755 --- a/src/main/java/emissary/pool/MoveSpool.java +++ b/src/main/java/emissary/pool/MoveSpool.java @@ -224,7 +224,7 @@ public void run() { logger.error("Unable to start agent, payload " + itemName + " is irretrievably lost", t); try { pool.returnAgent(agent); - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.error("Unable to return agent to the pool", ex); } } else { diff --git a/src/main/java/emissary/pool/PayloadLauncher.java b/src/main/java/emissary/pool/PayloadLauncher.java index 4027a05858..aad3b8bcb7 100644 --- a/src/main/java/emissary/pool/PayloadLauncher.java +++ b/src/main/java/emissary/pool/PayloadLauncher.java @@ -21,6 +21,7 @@ public class PayloadLauncher { private static final Logger logger = LoggerFactory.getLogger(PayloadLauncher.class); + @SuppressWarnings("CatchingUnchecked") public static boolean launch(Object payload, IServiceProviderPlace place, int errorCount, List itineraryItems) throws EmissaryException { String payloadName = PayloadUtil.getName(payload); diff --git a/src/main/java/emissary/roll/RollManager.java b/src/main/java/emissary/roll/RollManager.java index fa3ffb0733..d752436854 100644 --- a/src/main/java/emissary/roll/RollManager.java +++ b/src/main/java/emissary/roll/RollManager.java @@ -64,7 +64,7 @@ protected void init(Configurator configG) { try { Map map = configG.findStringMatchMap(roller + "_"); cfgRollers.add(RollUtil.buildRoller(map)); - } catch (Exception e) { + } catch (RuntimeException e) { log.warn("Unable to configure Rollable for: {}", roller); } } diff --git a/src/main/java/emissary/server/api/Shutdown.java b/src/main/java/emissary/server/api/Shutdown.java index 6f3f917c80..d0bf6418ac 100644 --- a/src/main/java/emissary/server/api/Shutdown.java +++ b/src/main/java/emissary/server/api/Shutdown.java @@ -46,13 +46,13 @@ protected Response shutdown(HttpServletRequest request, boolean force) { } else { EmissaryServer.stopServer(); } - } catch (Exception e) { + } catch (RuntimeException e) { // swallow } System.exit(0); }).start(); return Response.ok("Shutdown initiated. Come again soon!").build(); - } catch (Exception e) { + } catch (RuntimeException e) { LOG.warn("Exception trying to initiate shutdown: {}", e.getMessage()); return Response.serverError().entity("Error trying to initiate shutdown").build(); } diff --git a/src/main/java/emissary/server/mvc/internal/RollOutputsAction.java b/src/main/java/emissary/server/mvc/internal/RollOutputsAction.java index a3346ac725..78b4408c92 100644 --- a/src/main/java/emissary/server/mvc/internal/RollOutputsAction.java +++ b/src/main/java/emissary/server/mvc/internal/RollOutputsAction.java @@ -1,6 +1,7 @@ package emissary.server.mvc.internal; import emissary.core.Namespace; +import emissary.core.NamespaceException; import emissary.core.ResourceWatcher; import emissary.output.DropOffPlace; import emissary.output.filter.IDropOffFilter; @@ -39,7 +40,7 @@ public Response rollOutputs(@QueryParam("filter") List outputFilterNames f.close(); outputNames.append(" ").append(filter); } - } catch (Exception ex) { + } catch (RuntimeException ex) { outputNames.append(" ").append(filter).append("-FAILED"); logger.error("Could not roll " + filter, ex); } @@ -53,7 +54,7 @@ public Response rollOutputs(@QueryParam("filter") List outputFilterNames } return Response.ok().entity("Output Rolled: " + outputNames).build(); - } catch (Exception ex) { + } catch (NamespaceException | RuntimeException ex) { logger.warn("Could not roll outputs", ex); return Response.ok().entity("Could not roll outputs: " + ex.toString()).build(); } diff --git a/src/main/java/emissary/transform/decode/HtmlEscape.java b/src/main/java/emissary/transform/decode/HtmlEscape.java index 4b2a96a96d..a8b883df70 100644 --- a/src/main/java/emissary/transform/decode/HtmlEscape.java +++ b/src/main/java/emissary/transform/decode/HtmlEscape.java @@ -15,6 +15,7 @@ import javax.annotation.Nullable; @Deprecated(forRemoval = true) +@SuppressWarnings("all") public class HtmlEscape { /* our logger */ diff --git a/src/main/java/emissary/util/CharsetUtil.java b/src/main/java/emissary/util/CharsetUtil.java index 9d3e4eab3d..7d15d4721a 100755 --- a/src/main/java/emissary/util/CharsetUtil.java +++ b/src/main/java/emissary/util/CharsetUtil.java @@ -199,7 +199,7 @@ public static boolean isAscii(final String s) { return false; } } - } catch (Exception e) { + } catch (RuntimeException e) { return false; } return true; diff --git a/src/main/java/emissary/util/DateTimeFormatParser.java b/src/main/java/emissary/util/DateTimeFormatParser.java index 56794bf89b..bcae5a5fb1 100644 --- a/src/main/java/emissary/util/DateTimeFormatParser.java +++ b/src/main/java/emissary/util/DateTimeFormatParser.java @@ -58,7 +58,7 @@ protected static void configure() { } try { zone = ZoneId.of(configG.findStringEntry("TIME_ZONE")); - } catch (Exception e) { + } catch (RuntimeException e) { logger.error("There was an issue reading the time zone from the config file"); return; } @@ -88,7 +88,7 @@ private static void loadDateTimeEntries(Configurator configG, String entryType, } final DateTimeFormatter dtf = initialDtf; dateFormats.add(dtf); - } catch (Exception ex) { + } catch (RuntimeException ex) { logger.debug("{} entry '{}' cannot be parsed", entryType, dateFormatEntry, ex); } } diff --git a/src/main/java/emissary/util/DateTimeFormatParserLegacy.java b/src/main/java/emissary/util/DateTimeFormatParserLegacy.java index de6de1565b..a52bdcd68c 100644 --- a/src/main/java/emissary/util/DateTimeFormatParserLegacy.java +++ b/src/main/java/emissary/util/DateTimeFormatParserLegacy.java @@ -13,7 +13,7 @@ import java.util.List; @Deprecated -@SuppressWarnings("JavaUtilDate") +@SuppressWarnings("all") public class DateTimeFormatParserLegacy { protected static final Logger logger = LoggerFactory.getLogger(DateTimeFormatParserLegacy.class); diff --git a/src/main/java/emissary/util/DisposeHelper.java b/src/main/java/emissary/util/DisposeHelper.java index b0351c3816..099bde6485 100644 --- a/src/main/java/emissary/util/DisposeHelper.java +++ b/src/main/java/emissary/util/DisposeHelper.java @@ -120,7 +120,7 @@ public static void execute(final IBaseDataObject ibdo) { for (final Runnable runnable : DisposeHelper.get(ibdo)) { try { runnable.run(); - } catch (final Exception e) { + } catch (final RuntimeException e) { LOGGER.warn("Exception while executing Runnable for {}", ibdo.shortName(), e); } } diff --git a/src/main/java/emissary/util/UnixFile.java b/src/main/java/emissary/util/UnixFile.java index d327f4ff56..9765f462d8 100644 --- a/src/main/java/emissary/util/UnixFile.java +++ b/src/main/java/emissary/util/UnixFile.java @@ -117,13 +117,9 @@ public static String evaluateBinaryProperty(@Nullable byte[] bytes) { return FILETYPE_EMPTY; } - for (int i = 0; i < bytes.length; i++) { - try { - if (bytes[i] < 32) { - return FILETYPE_BINARY; - } - } catch (Exception ignore) { - log.error("Exception on evaulateBinaryProperty", ignore); + for (byte aByte : bytes) { + if (aByte < 32) { + return FILETYPE_BINARY; } } return FILETYPE_ASCII;