-
Notifications
You must be signed in to change notification settings - Fork 909
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
Refuse to use a decorating Client
and Service
if as()
or serviceAdded()
is not overriden.
#1958
Comments
I would like to also tackle this one :) |
Thank you! 🙇♂️ |
Sorry guys, a month has already passed and I yet couldn't get to it. I will try to work on it over the course of the next week. 😞 |
No worries. I really appreciate that you're trying to help us! 🙇♂️ |
@trustin Could I try this issue? |
I'm not trustin, but I could tell "Yes, please!" 😄 |
🤣 Yes, please! |
…iceAdded()` Motivation: If a user writes a decorator with curried lambda style, the given decorator will not override `as()` or `serviceAdded()`. line#1958 ```java sb.service("/svc", myService.decorate(delegate -> (ctx, req) -> { ... return delegate.serve(ctx, req); })); ``` The decorated will not call `ServiceCallbackInvoker.invokeServiceAdded()` properly. Modifications: - Add `DecoratorUtil` for validating decorators using reflection. - Add the validation logic to `{Http,Rpc}Service.decorate()`, `ClientDecoration.*decorate()`, `RouteDecoratingService()`. Result: You can now get `IllegalArgumentException` when the specified decorator does not override `as()` or `serviceAdded()`
…iceAdded()` Motivation: If a user writes a decorator with curried lambda style, the given decorator will not override `as()` or `serviceAdded()`. line#1958 ```java sb.service("/svc", myService.decorate(delegate -> (ctx, req) -> { ... return delegate.serve(ctx, req); })); ``` The decorated will not call `ServiceCallbackInvoker.invokeServiceAdded()` properly. Modifications: - Add `DecoratorUtil` for validating decorators using reflection. - Add the validation logic to `{Http,Rpc}Service.decorate()`, `ClientDecoration.*decorate()`, `RouteDecoratingService()`. Result: You can now get `IllegalArgumentException` when the specified decorator does not override `as()` or `serviceAdded()`
…iceAdded()` Motivation: If a user writes a decorator with curried lambda style, the given decorator will not override `as()` or `serviceAdded()`. line#1958 ```java sb.service("/svc", myService.decorate(delegate -> (ctx, req) -> { ... return delegate.serve(ctx, req); })); ``` The decorated will not call `ServiceCallbackInvoker.invokeServiceAdded()` properly. Modifications: - Add `DecoratorUtil` for validating decorators using reflection. - Add the validation logic to `{Http,Rpc}Service.decorate()`, `ClientDecoration.*decorate()`, `RouteDecoratingService()`. Result: You can now get `IllegalArgumentException` when the specified decorator does not override `as()` or `serviceAdded()` Fixes line#1958
I've just realized this stops a user from using That means, I think we can't validate anything this way. 😭 |
A common mistake a user makes when writing a decorator is:
The above decorator is not correct because the returned service does not override the default
as()
andserviceAdded()
implementation. A correct usage is:We can detect such a mistake by checking if the decorator overrides the default
as()
andserviceAdded()
implementation using Java reflection API and raise an exception.The text was updated successfully, but these errors were encountered: