Fix #340 - Clarify extension handling#530
Conversation
|
This has been open for almost a month. I was expecting more feedback. I'm moving this out of draft and currently intend to merge in the next week or so. |
|
Sorry, I was out on break and missed this one. |
|
I'll try to get feedback on this within the next 24 hours. |
|
|
||
| Extension[] extensions() default {}; | ||
|
|
||
| @interface Extension { |
There was a problem hiding this comment.
I would consider moving this outside of ClientEndpoint so it could be used on the Server side as well, because there is ServerEndpointConfig.getExtensions but no equivalent on the ServerEndpoint annotation.
There was a problem hiding this comment.
Moving this outside of ClientEndpoint would create a conflict with the Extension interface. Making the annotation available on the server side was also discussed in #340 and no use case was identified. Do you have a use case for this?
There was a problem hiding this comment.
It is the use case of ServerEndpointConfig#getExtensions which does not make sense to me.
But it seems to me that either ServerEndpointConfig#getExtensions should be deprecated, or there should be an equivalent API on the @ServerEndpoint annotation.
But for example I would imagine something like this, which would allow you to negotiate a specific extension without setting a custom configurator.
@ServerEndpoint(value = "/", extensions = { @Extension(name = "permessage-deflate")})
public class MyServerEndpoint
{
// ...
}There was a problem hiding this comment.
I think that would work for ServerEndpointConfig#getExtensions (matched with new @Extension support in @ServerEndpoint) if the intersection of those extensions and what the container supports was passed as installed to ServerEndpointConfig.Configurator.getNegotiatedExtensions. That would also need explicitly documenting in the spec.
That then begs the question what do we name @Extension. We can't use the obvious jakarta.websocket.Extension as that clashes with the existing interface. @ExtensionConfig?
api/server/src/main/java/jakarta/websocket/server/ServerEndpointConfig.java
Outdated
Show resolved
Hide resolved
markt-asf
left a comment
There was a problem hiding this comment.
Thanks for the review. I'll make the updates as per my comments shortly and we can continue to discuss the unresolved points.
|
|
||
| Extension[] extensions() default {}; | ||
|
|
||
| @interface Extension { |
There was a problem hiding this comment.
Moving this outside of ClientEndpoint would create a conflict with the Extension interface. Making the annotation available on the server side was also discussed in #340 and no use case was identified. Do you have a use case for this?
api/server/src/main/java/jakarta/websocket/server/ServerEndpointConfig.java
Outdated
Show resolved
Hide resolved
api/server/src/main/java/jakarta/websocket/server/ServerEndpointConfig.java
Outdated
Show resolved
Hide resolved
api/server/src/main/java/jakarta/websocket/server/ServerEndpointConfig.java
Outdated
Show resolved
Hide resolved
|
|
||
| Extension[] extensions() default {}; | ||
|
|
||
| @interface Extension { |
There was a problem hiding this comment.
It is the use case of ServerEndpointConfig#getExtensions which does not make sense to me.
But it seems to me that either ServerEndpointConfig#getExtensions should be deprecated, or there should be an equivalent API on the @ServerEndpoint annotation.
But for example I would imagine something like this, which would allow you to negotiate a specific extension without setting a custom configurator.
@ServerEndpoint(value = "/", extensions = { @Extension(name = "permessage-deflate")})
public class MyServerEndpoint
{
// ...
}|
How would we handle the common use case of rejecting or denying a specific extension from negotiating? Can someone setup a server endpoint to reject permessage-deflate? @ServerEndpoint(value = "/", reject-extensions = { @Extension(name = "permessage-deflate")})
public class MyServerEndpoint
{
// ...
}or @ServerEndpoint(value = "/", extensions = { @Extension(name = "permessage-deflate", reject=true)})
public class MyServerEndpoint
{
// ...
}or @ServerEndpoint(value = "/", extensions = { @Extension(name = "!permessage-deflate")})
public class MyServerEndpoint
{
// ...
} |
Do we need to? The mode for the client is that it declares the list of extensions it is prepared to support. Given the small number of extensions, that model should work for the server too. If we did adopt this feature, I'd lean towards the first option - although I'd use |
Yes, it is a common use case. |
|
Sorry, not progressing this as fast as I would like. Other tasks keep getting in the way.
While I like the use of |
e81ac89 to
f7304f7
Compare
|
Updated PR for review. Once we have agreement, I'll likely refactor the commits to make the changes to main cleaner. |
|
I'll have a chance to go over this better early next week. |
|
Small comment -- Change should be listed under the change log of the spec document. |
|
Re-opening |
f7304f7 to
dc7e01c
Compare
|
Just rebasing the PR. |
|
I'll defer to @lachlan-roberts |
|
I think we should consider the use-case of declaring that no extensions should be negotiated, because an Say the server supports extensions
Perhaps this include/exclude semantic adds too much complexity considering there is only two extensions defined in the extension registry. But if we are to keep it, think we should at least specify that the allow-list takes precedence, so that |
|
I think the case has been made above for the allow/deny semantic so I am assuming we need to keep it. I like your explanatory table. I'll add that to the spec doc. I agree the allow list should take precedence and can document that. How about I think that covers all of the points raised. If there is agreement on all of these I can update the PR and add start working on the TCK. |
Okay, that works.
+1 from me |
+1 from me too. |
Keeping this in draft at this point as further changes are expected.
The specification document changes are mostly complete although I am expecting the wording to be improved based on review.
The API changes are intended as a starting point. I'll add some Javadoc once the API is more settled.
Feedback welcome. I'll leave it at least a couple of weeks before moving this to non-draft and merging.