Refuse to use a decorating `Client` and `Service` if `as()` or `serviceAdded()` is not overriden.
See original GitHub issueA common mistake a user makes when writing a decorator is:
ServerBuilder sb = new ServerBuilder();
sb.service("/svc", myService.decorate(delegate -> (ctx, req) -> {
...
return delegate.serve(ctx, req);
}));
The above decorator is not correct because the returned service does not override the default as()
and serviceAdded()
implementation. A correct usage is:
sb.service("/svc", myService.decorate((delegate, ctx, req) -> {
return delegate.serve(ctx, req);
});
// or
sb.service("/svc", myService.decorate(delegate -> new SimpleDecoratingService(delegate) {
...
return delegate().serve(ctx, req);
...
}));
We can detect such a mistake by checking if the decorator overrides the default as()
and serviceAdded()
implementation using Java reflection API and raise an exception.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Dealing With Clients Who Refuse To Pay - Smashing Magazine
Cons # If you are dealing with a client who is already refusing to pay for completed work, chances are that this respectful...
Read more >Dependency Injection error: Unable to resolve service for type ...
NET Core MVC application and use Dependency Injection and Repository Pattern to inject a repository to my controller. However, I am getting an...
Read more >Nonattest Services Frequently Asked Questions and Answers
and scope of the nonattest service. Overseeing the service does not require that the individual designated by the attest client must supervise the...
Read more >Publication 35, Interior Designers and Decorators - CDTFA
This publication is intended as a general guide to the Sales and Use Tax Law and Regulations as they apply to interior designers...
Read more >Fix Packs Available for IBM API Connect v2018.x
List of fix packs for IBM API Connect v2018.x.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🤣 Yes, please!
I’m not trustin, but I could tell “Yes, please!” 😄