-
Notifications
You must be signed in to change notification settings - Fork 45
Fix #340 - Clarify extension handling #530
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.