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

HV-1131 Deferring retrieval of default MI #556

Merged
merged 3 commits into from Oct 18, 2016

Conversation

gunnarmorling
Copy link
Member

@gsmet I've found an alternative approach for the EL issue. The idea is to defer the retrieval of the default message interpolator until it's actually needed (either by calling getDefaultMessageInterpolator() or when bootstrapping the VF and no other MI has been given). That way the instantiation of the expression factory can simply be done in the 'ctor of ResourceBundleMessageInterpolator, not requiring any synchronization.

I've also rewritten the test so it doesn't need reflection in the actual test routine. I've reworked your commit so it adds the new test and your fixes around the test class loader, but ommitted your original approach for fixing the issue for the sake of a clean history.

@@ -400,7 +404,7 @@ public ClassLoader getExternalClassLoader() {

@Override
public final MessageInterpolator getDefaultMessageInterpolator() {
return defaultMessageInterpolator;
return new ResourceBundleMessageInterpolator( defaultResourceBundleLocator );
Copy link
Member

Choose a reason for hiding this comment

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

I thought about this approach but I must admit I really disliked the fact that we instantiate a new ResourceBundleMessageInterpolator each time we call this method (and getMessageInterpolator). I would expect us to return the same object for each call.

Thinking about it and as I noticed Configuration is not supposed to be thread safe, couldn't we store the interpolators the first time the methods are called? That would solve this issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not really concerned about it (these methods are not expected to be invoked gazillion of times). Is there anything specific you base your expectation for the same instance to be returned upon?

Storing them as you say should work; ConfigurationState (unlike Configuration) doesn't explicitly state that it's not thread-safe, but I think it's a reasonable assumption then that it isn't.

Copy link
Member

Choose a reason for hiding this comment

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

Just to be clear on my worries: it's named like a getter and it used to work like a getter so I didn't think it was such a trivial change to make it return a different instance for each call. I don't think it's an inappropriate expectation to have it behave like a getter.

@gsmet
Copy link
Member

gsmet commented Oct 17, 2016

I've also rewritten the test so it doesn't need reflection in the actual test routine.

Nice!

@gsmet gsmet self-assigned this Oct 17, 2016
@gunnarmorling
Copy link
Member Author

@gsmet Pushed an update.

@gsmet gsmet merged commit c9948da into hibernate:master Oct 18, 2016
@gunnarmorling
Copy link
Member Author

gunnarmorling commented Oct 18, 2016 via email

@gsmet
Copy link
Member

gsmet commented Oct 18, 2016

Merged, thanks!

@gunnarmorling gunnarmorling deleted the HV-1131 branch October 19, 2016 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants