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

ARTEMIS-1895 - Add duplicate metadata failure callback to ActiveMQServerPlugin #2116

Closed
wants to merge 1 commit into from

Conversation

cshannon
Copy link
Contributor

Add a callback on duplicate metadata which will allow extra functionality to be added.

@@ -263,6 +264,8 @@ private void validateClientID(ClientSession validateSession, String clientID) th
} catch (ActiveMQException e) {
if (e.getType() == ActiveMQExceptionType.DUPLICATE_METADATA) {
throw new InvalidClientIDException("clientID=" + clientID + " was already set into another connection");
} else {
throw new InvalidClientIDException("Error setting clientID=" + clientID + ": " + e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original exception here may not be related to InvalidClientId, seems a bit dangerous to catchall and throw like this. Maybe bubble up or convert the exception, at least link the exception and add the intial cause.

@cshannon
Copy link
Contributor Author

cshannon commented May 30, 2018

@michaelandrepearce - good point, i fixed it to bubble up the ActiveMQException so it is handled properly by the client

con.setClientID("valid");
con2.setClientID("valid");
fail("Should have failed for duplicate clientId");
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test that explicit exception type is thrown not just any old exception. As probably should fail if an unexpectes exception is ever thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched it to catch the InvalidClientIdException that gets thrown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added another test to verify that ActiveMQException bubbles up and is converted to a JMSException by the client

fail("Should have failed for duplicate clientId");
} catch (InvalidClientIDException e) {
assertEquals(1, duplicateCount.get());
throw e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem here is assert will be bypassed and test will still pass if another exception thrown as tests expects JMSException.

Expects should be explicit and need a catch all with and assert fail

@cshannon
Copy link
Contributor Author

I removed the re-throw and the expect for the JMSException so it will only pass on InvalidClientIDException as that is the only type that should be thrown

@michaelandrepearce
Copy link
Contributor

Looks good to me

@cshannon
Copy link
Contributor Author

cshannon commented Jun 4, 2018

@clebertsuconic - is this ok to merge?

@cshannon
Copy link
Contributor Author

cshannon commented Jun 4, 2018

I don't think it's related as the test it failed on doesn't have a plugin registered. I tried to see if I could trigger it to re-run the build in travis ci but i didn't see a way to do that.

@clebertsuconic
Copy link
Contributor

clebertsuconic commented Jun 4, 2018

The easiest way to rebuild is to.

Git commit —amend
Git push -f

…verPlugin

Add a callback on duplicate metadata which will allow extra
functionality to be added.
@cshannon
Copy link
Contributor Author

cshannon commented Jun 4, 2018

The build looks good now

@clebertsuconic
Copy link
Contributor

thanks a lot.. merging

@asfgit asfgit closed this in 81935cf Jun 4, 2018
@cshannon cshannon deleted the ARTEMIS-1895 branch February 11, 2020 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants