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
[RESTEASY-2525]:Make restclient read config only once #2354
Conversation
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.
@jimma the changes look ok to me, but I'm wondering if they go against what you're saying in https://issues.redhat.com/browse/RESTEASY-2525?focusedCommentId=14038622&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14038622 . Can you clarify please? Thanks
Hi @jimma, I might be missing something.
?? |
I checked this with @dependant annotation, and it looks we can still improve @Depandant scope to read only config once by this PR. I add this info to JIRA too. |
@ronsigal The rest client default scope is @dependant and default scope of resource is request scope, so each request will create this proxy along with a config read. From code debug, if there are all default setting as the , the config will be read for each resource method invocation. |
Hey @jimma, re: "the config will be read for each resource method invocation" Yes, I agree. But I don't see how your update changes that. Maybe if the flag and the map were static ... . I think that making them static would be safe, since the values come from sources that, at least for the standard ConfigSources, shouldn't change after deployment. I'm not sure if that's true for the Wildfly specific ConfigSources like a file of directory names, though. In the question I posted on the JIRA, I'm wondering if Márk Petrényi is suggesting that, instead of looping through all of the names in all of the ConfigSources, it would be faster to look for the properties that are specific to MP REST Client. -Ron |
The flag will be checked to skip the properties read and directly return the result map when it's true.
if we have multiple deployments in container, will static get all deployments shares the same config values from the first read deployment because RestClientDelegateBean
Looks these properties are read and configured before getConfigProperties() : https://github.com/resteasy/Resteasy/blob/master/resteasy-client-microprofile/src/main/java/org/jboss/resteasy/microprofile/client/RestClientDelegateBean.java#L120~L126 ? |
re: "The flag will be checked to skip the properties read and directly return the result map when it's true." What am I missing? If the scope of the REST Client is @dependent, and it lives in a @request scoped resource, then getConfigProperties() would get called once for each invocation, right? So there won't be a second pass through getConfigProperties() when readConfig is true. ?? re: "Looks these properties are read and configured before getConfigProperties()" Ah, yes, you're right. So getConfigProperties() is re-checking those properties, which is redundant. I haven't checkout which properties are not checked by the time we get to getConfigProperties(), but those, if any, could also be checked explicitly. |
This is all true with this PR change.
getConfigProperties() seems not redundant. It only reads the property with prefix like "myClient/property/" from mp-config. |
Hi @jimma,
But what I'm saying is that checking
it looks to me like
will loop through all of the properties (even if it doesn't look at them because of the if statement), including "myClient/mp-rest/url", "myClient/mp-rest/uri", etc., which have already been read. Moreover, that requires accessing all of the ConfigSources just to get the names, which I think is what Márk Petrényi is saying might be expensive. |
From debug, by default @dependant scope creates client proxy and calls getConfigProperites() for each request:
Ah. That is something we need to have a look. I don't know much about microprofile-config. Is there api we can leverage to filter out these properties already read ? |
Hey @jimma,
I think I see where we're disagreeing. I just noticed (or noticed again, maybe) that RestClientDelegateBean is managed by CDI. Offhand, I can't remember how CDI handles a @dependent bean. Is it treated like a stateless EJB, where there are one or more backing instances that get reused? Or is it recreated each time? I've been thinking the latter, in which case
I'm not sure. I'll take a look. |
Given the MicroProfile is moved to https://github.com/resteasy/resteasy-microprofile I'm closing this. |
No description provided.