Skip to content
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

FISH-758 Fault Tolerance Annotations Not Applied to Rest Client Interfaces #5315

Merged
merged 6 commits into from
Jun 23, 2021

Conversation

Pandrex247
Copy link
Member

@Pandrex247 Pandrex247 commented Jun 22, 2021

Description

Bug fix.

The MicroProfile Rest Client spec has an untested requirement that FT annotations get applied to Rest Client interfaces.
https://github.com/eclipse/microprofile-rest-client/blob/master/spec/src/main/asciidoc/integration.asciidoc#microprofile-fault-tolerance

Weld wasn't picking up our synthetic "not quite a stereotype" Fault Tolerance interceptor as an interceptor for the individual FT annotations, as it attempts to match annotations to interceptors via this method - FaultTolerance only matches FaultTolerance, not Retry and only Retry.

The way around this was to go back to the old style of having an interceptor for each individual FT annotation, which becomes a problem when it comes to attempting to resolve Fallback as you can't write an interceptor for this in the usual way (marking a class with Fallback & Interceptor and adding an AroundInvoke method).
Alternatively, we could do as we've done here and register the interceptor programmatically as an interceptor for the FT annotations.

Important Info

Blockers

None.

Testing

New tests

IT added to Payara Samples.

Testing Performed

Ran the FT TCK.
Ran Rudy's example test which demonstrates the Retry annotation working on a Rest Client interface.

Testing Environment

Windows 10, JDK 8
WSL OpenSUSE Leap 15.2, JDK 8

Documentation

N/A

Notes for Reviewers

I feel like this block is both over and under-engineered and I'm missing a much simpler way of determining the priority of each interceptor - this solution seems fragile.
https://github.com/payara/Payara/compare/master...Pandrex247:FISH-758?expand=1#diff-d1250f7d0ca1e02fa4c81c96aa7ef9d2c7045b6e4f7bdab566ea282ad3c60940R149-R248

Pandrex247 and others added 3 commits June 22, 2021 14:55
Got Retry and other annotations to get detected for Rest Client.
Asynchronous throws an exception however during deployment so is
commented out, and not sure how to tackle Fallback due to its
special nature of not allowing targets of TYPE (class).

Signed-off-by: Andrew Pielage <[email protected]>
@Pandrex247 Pandrex247 requested a review from pdudits June 22, 2021 14:17
Copy link
Contributor

@pdudits pdudits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether you keep the binary search or go for simpler approach, I think that ordering part still needs a unit test.

interceptorType.configureAnnotatedType()
.remove(annotation -> annotation instanceof Priority)
.add(new PriorityLiteral(priorityOverride.get()));
void enableInterceptor(@Observes AfterTypeDiscovery afterTypeDiscovery) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too much code to just believe in without a unit test ;)

Binary search is of course the correct approach since we already know that the list is sorted. But we're also looking at one time insertion in a table that is usually handful of items.

Personally I'd settle for linear scan of the list to find first interceptor with higher or equal priority and ours just before it. But the unit test requirement still holds ;)

Signed-off-by: Andrew Pielage <[email protected]>
Signed-off-by: Andrew Pielage <[email protected]>
@Pandrex247 Pandrex247 marked this pull request as ready for review June 23, 2021 10:47
@Pandrex247
Copy link
Member Author

Jenkins test please

@Pandrex247 Pandrex247 merged commit dbbc941 into payara:master Jun 23, 2021
@Pandrex247 Pandrex247 deleted the FISH-758 branch June 23, 2021 14:44
JamesHillyard pushed a commit to JamesHillyard/Payara that referenced this pull request Oct 28, 2021
FISH-758 Fault Tolerance Annotations Not Applied to Rest Client Interfaces
JamesHillyard added a commit to JamesHillyard/Payara that referenced this pull request Dec 22, 2021
JamesHillyard pushed a commit to JamesHillyard/Payara that referenced this pull request Dec 23, 2021
FISH-758 Fault Tolerance Annotations Not Applied to Rest Client Interfaces

Signed-off-by: JamesHillyard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants