markap14 commented on a change in pull request #4952:
URL: https://github.com/apache/nifi/pull/4952#discussion_r726516881



##########
File path: 
nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteBulletinReportingTask.java
##########
@@ -162,23 +161,21 @@ public void onTrigger(final ReportingContext context) {
 
             final long transferMillis = 
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
             getLogger().info("Successfully sent {} Bulletins to destination in 
{} ms; Transaction ID = {}; First Event ID = {}",
-                    new Object[]{bulletins.size(), transferMillis, 
transactionId, bulletins.get(0).getId()});
-        } catch (final Exception e) {
+                    bulletins.size(), transferMillis, transactionId, 
bulletins.get(0).getId());
+        } catch (ProcessException e) {
+            throw e;
+        } catch (Exception e) {
             if (transaction != null) {
                 transaction.error();
             }
-            if (e instanceof ProcessException) {
-                throw (ProcessException) e;
-            } else {
-                throw new ProcessException("Failed to send Bulletins to 
destination due to IOException:" + e.getMessage(), e);
-            }
+            throw new ProcessException("Failed to send Bulletins to 
destination due to IOException:" + e.getMessage(), e);

Review comment:
       @Lehel44 the code was structured that way because if there is ever an 
Exception thrown, we must evaluate `if (transaction != null) { 
transaction.error(); }`. By refactoring this, we no longer evaluate that if 
`ProcessException` is thrown - only if any other Exception is thrown.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to