-
Notifications
You must be signed in to change notification settings - Fork 121
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
Clarification: Reconfiguration of Client #1271
Comments
I don't understand how the separation of the calls to |
Maybe I'm not understanding either, but I agree with @spericas. There is nothing in the spec nor the JavaDoc that says a client instance is immutable. Those chained methods come from the
|
The behavior can actually be good to emphasize if not already done so in the Spec. While the mutability of the client can be clear, the consequences as in the following example can be surprising:
Even though the abortion status was set on a "different" client, the behavior of the first client is changed and the first request returns status 200, and the second 555. While with the client the behavior is quite clear, with the |
The point of my question simply is: Neither the spec nor the JavaDocs explicitly mandate that the result of
To sum up, I do not plea for any particular solution, but only for a small change of the JavaDocs that MANDATE (a) or (b). |
"SHOULD" is not "MUST". Do we all agree that what we actually want the runtime to do is "MUST" then we have to write "MUST". |
FWIW I'm fine if we want a clarification, but I don't really see how it's not obvious. IoW if Client client = ClientBuilder.newClient();
client.property("MyProperty", "MyValue")
.register(MyProvider.class)
.register(MyFeature.class); if the Client c2 = client.register(Foo.class).property("MyProperty", "Bar"); would not create a new client. I don't really see how it could be interpreted any other way TBH. Again, though clarification is totally fine. |
@jamezp Isn't the problem obvious? See: Client client = ClientBuild.newClient(); // client refers to object 1 initially, which is immutable
client.property("MyProperty", "MyValue") // object 1 is untouched, property() returns a modified immutable copy -> object 2
.register(MyProvider.class) // object 2 is untouched, register() returns a modified immutable copy -> object 3
.register(MyFeature.class) // object 3 is untouched, register() returns a modified immutable copy -> object 4 I agree that this interpretation is wrong for
I understand that you all share the vision:
So let's simply agree to clearly say exactly that in the JavaDocs (I would volunteer for the needed changes). (BTW, just in case you wonder where this discussion comes from: Yes, there are use cases where it would make sense to be able to have a lightweight Client clone with different configuration -- but this is is a separate discussion...) |
I agree that being explicit with the documentation makes sense. |
A JAX-RS
Client
can be configured like this (example taken from JavaDocs):After these lines,
client
references to an instance that has the propertyMyProperty
set toMyValue
and that hasMyProvider
andMyFeature
registered.What neither the Jakarta REST Specification not the
Client
JavaDocs tell is, what happens toclient
if we extend the example like this:I assume it is undisputed that
c2
refers to aClient
additionally havingFoo
registered and propertyMyProperty
changed toBar
.But what about
client
? Doesclient
(likec2
) also haveFoo
registered and propertyBar
set toMayValue
now, or isclient
still holding the valueMyValue
and does not haveFoo
registered?We should discuss this question, find a concensus, and adapt the JavaDocs.
Opinions?
The text was updated successfully, but these errors were encountered: