-
Notifications
You must be signed in to change notification settings - Fork 894
[RESTEASY-1865] SynchronousDispatcher #getResource not returning Resource Instance #1520
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
Conversation
| obj = factory.createResource(request, response, this); | ||
| } | ||
| else | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not indented the else branch as it would have caused very confusing diff
|
Would this be OK for other implementations of |
|
@dansiviter This solution works and was tested for SingletonResource only. To have more generic solution, I advice to create it as a complex enhancement since we don't have any more relevant test cases.provided by the bug reporter. |
| */ | ||
| public <T> T injectedInstance(Class<? extends T> clazz, HttpRequest request, HttpResponse response) | ||
| { | ||
| Constructor<?> constructor = PickConstructor.pickSingletonConstructor(clazz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation of the Constructor object should be moved within else part of the if you added below, shouldn't it?
6dd43f9 to
1287f43
Compare
|
@asoldano Done |
asoldano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm changing the review, as I've just noticed that there's a regression in unit tests; @rnetuka , can you have a look please?
66adf1c to
78f4e7e
Compare
78f4e7e to
d4024f5
Compare
|
Fixed. Please, review again. Particulary this line: (within changed files) |
|
@rnetuka thanks, sorry for the late reply, I've been on PTO and then catching up. I don't see problems in the line that you mentioned. Now that I think more about this PR, though, I'm thinking that the hashmap you're adding should be made a thread safe... WDYT? |
|
Hi @rnetuka, I don't see anything in the JAX-RS spec (2.0 or 2.1) that suggests that the resource returned by ResourceContext.getResource() should be any particular iinstance. The javadoc says
[My bold emphasis.] Could you elaborate? -Ron |
|
Hi @rnetuka, there are a couple of outstanding questions here. Any thoughts? |
| else root.addInvoker(classExpression, fullpath, locator); | ||
| } | ||
|
|
||
| if (rf instanceof SingletonResource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rnetuka,
I'm questioning whether this should be in
protected void register(ResourceFactory rf, String base, ResourceClass resourceClass)
{
for (ResourceMethod method : resourceClass.getResourceMethods())
{
processMethod(rf, base, method);
}
for (ResourceLocator method : resourceClass.getResourceLocators())
{
processMethod(rf, base, method);
}
}
Otherwise, you'll be calling registerSingletonResource() for each method, no?
-Ron
|
Thank you for the contribution. We are cleaning up older PR's that seem to be stale. If you feel this is still an issue please feel free to re-open. |
JIRA: https://issues.jboss.org/browse/RESTEASY-1865
dispatcher.getRegistry().addSingletonResource(...) works for ResourceMethodInvoker (returned object is the proper singleton), but not for resourceContext.getResource(...). Here, the object being returned is simply constructed one by ResteasyProviderFactory using a constructor.