You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/03/08 19:18:44 UTC

[GitHub] [nifi] markap14 commented on a change in pull request #3351: NIFI-2933 Remote input/output ports at any PG

markap14 commented on a change in pull request #3351: NIFI-2933 Remote input/output ports at any PG
URL: https://github.com/apache/nifi/pull/3351#discussion_r263537710
 
 

 ##########
 File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/connectable/LocalPort.java
 ##########
 @@ -67,6 +78,33 @@ public boolean isValid() {
         return validationErrors;
     }
 
+    @Override
+    public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) {
+        if (publicPort != null) {
+            // If this is a publicly accessible port, then process remote transactions first.
+            publicPort.onTrigger(context, sessionFactory);
+        }
+
+        // Then process local connections if it has any local outgoing connection.
+        if (getConnections(Relationship.ANONYMOUS).isEmpty()) {
+            return;
+        }
+
+        final ProcessSession session = sessionFactory.createSession();
+
+        try {
+            onTrigger(context, session);
+            session.commit();
+        } catch (final ProcessException e) {
+            session.rollback();
+            throw e;
+        } catch (final Throwable t) {
+            session.rollback();
+            throw new RuntimeException(t);
 
 Review comment:
   We should not wrap the Throwable in a RuntimeException. Instead, we can remove the entire `catch (final ProcessException e) {` block and change to:
   ```
   try {
     onTrigger(context, session);
     session.commit();
   } catch (final Throwable t) {
     session.rollback();
     throw t;
   }
   ```
   
   Because nothing that is called throws any checked exceptions, it means that we can just rethrow the Throwable.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services