You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by cshannon <gi...@git.apache.org> on 2017/08/07 14:52:02 UTC

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

GitHub user cshannon opened a pull request:

    https://github.com/apache/activemq-artemis/pull/1445

    ARTEMIS-1327 - Support checked exceptions in ActiveMQServerPlugin

    This will allow plugin writers to use checked exceptions when writing
    plugins

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cshannon/activemq-artemis ARTEMIS-1327

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq-artemis/pull/1445.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1445
    
----
commit 16843d54bc833d61bb879fa47f9832147b454d97
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Date:   2017-08-07T14:49:46Z

    ARTEMIS-1327 - Support checked exceptions in ActiveMQServerPlugin
    
    This will allow plugin writers to use checked exceptions when writing
    plugins

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1445#discussion_r131678813
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java ---
    @@ -514,8 +514,11 @@ public void connectionCreated(final ActiveMQComponent component,
           }
     
           ConnectionEntry entry = protocol.createConnectionEntry((Acceptor) component, connection);
    -      server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterCreateConnection(entry.connection) : null);
    -
    +      try {
    +         server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterCreateConnection(entry.connection) : null);
    +      } catch (Exception e) {
    +         throw new IllegalStateException("Error executing afterCreateConnection plugin method: " + e.getMessage(), e);
    --- End diff --
    
    shouldn't you just log on this case...
    
    I would expect any failures on the broker plugin to just be logged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1445#discussion_r131682621
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java ---
    @@ -537,7 +540,11 @@ public void connectionDestroyed(final Object connectionID) {
           if (conn != null && !conn.connection.isSupportReconnect()) {
              RemotingConnection removedConnection = removeConnection(connectionID);
              if (removedConnection != null) {
    -            server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            try {
    +               server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            } catch (Exception e) {
    +               throw new IllegalStateException("Error executing afterDestroyConnection plugin method: " + e.getMessage(), e);
    --- End diff --
    
    make it catch Throwable :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1445#discussion_r131680131
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java ---
    @@ -537,7 +540,11 @@ public void connectionDestroyed(final Object connectionID) {
           if (conn != null && !conn.connection.isSupportReconnect()) {
              RemotingConnection removedConnection = removeConnection(connectionID);
              if (removedConnection != null) {
    -            server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            try {
    +               server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            } catch (Exception e) {
    +               throw new IllegalStateException("Error executing afterDestroyConnection plugin method: " + e.getMessage(), e);
    --- End diff --
    
    Yep, good point, i'll switch it and push up a new version.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1445#discussion_r131678949
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java ---
    @@ -537,7 +540,11 @@ public void connectionDestroyed(final Object connectionID) {
           if (conn != null && !conn.connection.isSupportReconnect()) {
              RemotingConnection removedConnection = removeConnection(connectionID);
              if (removedConnection != null) {
    -            server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            try {
    +               server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            } catch (Exception e) {
    +               throw new IllegalStateException("Error executing afterDestroyConnection plugin method: " + e.getMessage(), e);
    --- End diff --
    
    same here.. I would just log.warn... you cannot interrupt the broker if someone deploys a bugged interceptor.. can you?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1445#discussion_r131683225
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java ---
    @@ -537,7 +540,11 @@ public void connectionDestroyed(final Object connectionID) {
           if (conn != null && !conn.connection.isSupportReconnect()) {
              RemotingConnection removedConnection = removeConnection(connectionID);
              if (removedConnection != null) {
    -            server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            try {
    +               server.callBrokerPlugins(server.hasBrokerPlugins() ? plugin -> plugin.afterDestroyConnection(removedConnection) : null);
    +            } catch (Exception e) {
    +               throw new IllegalStateException("Error executing afterDestroyConnection plugin method: " + e.getMessage(), e);
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    @cshannon take a look on #1446 please?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    @cshannon I will merge this now as I need to add something on the server plugins... 
    
    if there's anything wrong with it.. we can review it later, ok?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    @clebertsuconic - This looks good to me


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    What about expose activemqexception.  But swallow others?
    
    
    Let me amend my PR and will and you feedback. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis pull request #1445: ARTEMIS-1327 - Support checked exceptio...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/activemq-artemis/pull/1445


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    That would probably be ok, just as long there is some way to propagate an exception when the plugin writer wants to.  If we do that should we change the plugin interface to throw ActiveMQException instead of Exception?  I'm about to head out for the day but I'll take a look at your new PR in the morning.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    I pushed up a new version that logs the error a the warn level


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    @clebertsuconic - So I just realized that I don't think we want to swallow exceptions.  If there's an exception in the plugin don't we want it to propagate?  There are 2 cases for exceptions, the first is a buggy plugin and that just means the plugin should be fixed.  The second is if there is an actual error and I think that error should be propagated and not just logged.
    
    For example, one of my use cases for this is I want to validate clientIds.  So I want to throw an exception and reject a clientId in the beforeSessionMetadataAdded method if it doesn't meet some criteria and have it propagated back to the client.  (There's actually another Jira I need to open to make this work properly to make sure the exception is thrown back to the client).



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] activemq-artemis issue #1445: ARTEMIS-1327 - Support checked exceptions in A...

Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1445
  
    @clebertsuconic - Or another use case...say you want to write a custom authentication plugin.  You would normally want to throw something like a security exception, etc in the plugin methods but now you can't do that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---