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

Do not null the actual connection when delaying close. That means whe… #1022

Merged
merged 1 commit into from Sep 27, 2016

Conversation

tomjenkinson
Copy link
Contributor

@tomjenkinson tomjenkinson commented Jun 15, 2016

@nmcl
Copy link
Contributor

nmcl commented Jun 18, 2016

I've noticed a few commits like this which don't appear to have associated JIRAs. Am I missing something?

@tomjenkinson
Copy link
Contributor Author

Generally they are likely to be speculative ones. Occasionally "CI" ones might not have a Jira (i.e. the ones that AMS2 runs for us).

This one in particular has not been cleared for release into the code as I am not 100% on the strategy yet. I am just running CI on it to verify it does not break anything.

@nmcl
Copy link
Contributor

nmcl commented Jun 20, 2016

OK. Was looking for a JIRA which might explain what the issue was. What's the plan to address that aspect, i.e., speculative issues which don't (appear to) have descriptions on the (speculative) issue and hence can't solicit input from the wider team/community? Or would the plan be to escalate to a full JIRA if going beyond speculation and then asking for input?

@tomjenkinson
Copy link
Contributor Author

Precisely. At the moment I am working out if the change that makes the other project work, breaks our CI. Then I will look more closely at the change to see if it makes sense to make the change or make the dependent project change (i.e. is a bug in Narayana, enhancement in Narayana or bug in the third party project). Finally I will either create a forum post or an issue (depending on whether its an enhancement, bug or whatever).

For now I have just added the "hold" label to show this incomplete state - I should have done that before.

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@@ -125,13 +124,14 @@ public void beforeCompletion() { }
public void afterCompletion(int status) {
try {
connectionToTest.isClosed();
connectionToTest.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about that. This test is specifically for isClosed method. Close method is tested by closeConnectionInAfterCompletion.
I did that on purpose to make test units as small as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but its part of spec that you have to call connection.close if you call getConnection. I can move it out of the verify I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I can. I will move it down so it doesn't look wrong for the test

Copy link
Contributor

Choose a reason for hiding this comment

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

But connection wasn't really opened. xaDataSource is a mock, so instead of creating a connection it returns a mock connection.
Also message in the catch block is a bit misleading since you've removed close statement.

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 updated the message.
RE connection.close() I am not sure if you are saying it doesn't matter because we are using a mock in which case I would disagree because someone might change it from a mock to a real connection in the future and then it would break. OTOH aybe you are saying even with a real connection you would not need the .close in which case I can remove it.
I do see from the rest of your tests that you do have the .close()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will just add the comment then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, as you can see from the diff I have made the change you requested to not close connection however in doing so there is an issue that the close functionality is not executed:
https://github.com/tomjenkinson/narayana/blob/bcc7c01599e46fcd5e5412ce9277bda62146ddb0/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java#L388

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you have change to review this yet? I wonder about if adding the .close would also be useful if we in the future added pooling to ConnectionImpl. By not calling .close we would leak the connection not just from ConnectionManager but also this hypothetical pool.

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I didn't get a notification for some reason...
We would leak in the real application. But this is a unit test which doesn't use real connections. There is nothing to leak.
I'm not sure what you mean by close not being executed. Why would isClose execute it? You should check for closeImpl execution in closeConnectionInAfterCompletion test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi gytis, I don't think I am being clear here. The connection we would leak would be a ConnectionImpl.

But lets not talk hypothetical. If this test does not call connection.close() then the following line is not called: https://github.com/tomjenkinson/narayana/blob/bcc7c01599e46fcd5e5412ce9277bda62146ddb0/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java#L388

* own implementation!
*/

public class SupportsMultipleConnectionsModifier implements XAModifier, ConnectionModifier {
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and in some other places tab is used to indent rather than a space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, we don't normally worry about the code format but I will reformat with IntelliJ and see how that comes out

@gytis gytis assigned tomjenkinson and unassigned gytis Sep 23, 2016
@tomjenkinson
Copy link
Contributor Author

I just internationalized the log messages too

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@tomjenkinson tomjenkinson force-pushed the dontnullconnection branch 2 times, most recently from 38ddc13 to bcc7c01 Compare September 25, 2016 20:43
@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@jbosstm-bot
Copy link

@tomjenkinson
Copy link
Contributor Author

As agreed on HipChat I have made the change to use a ConnectionImple (rather than java.sql.Connection) and @gytis agreed I should merge it after that.

@tomjenkinson tomjenkinson merged commit 2cf35fa into jbosstm:master Sep 27, 2016
@tomjenkinson tomjenkinson deleted the dontnullconnection branch November 8, 2016 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants