Skip to content

Commit

Permalink
Merge pull request quarkusio#29171 from geoand/quarkusio#29170
Browse files Browse the repository at this point in the history
Fix CDI scope for classes that declare @ServerRequestFilter
  • Loading branch information
geoand authored Nov 10, 2022
2 parents 1cec84d + 5fcdbf4 commit 9fc44a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.function.Supplier;

import javax.annotation.Priority;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Priorities;
Expand Down Expand Up @@ -151,6 +152,7 @@ public void filter(ContainerRequestContext requestContext) throws IOException {
}
}

@ApplicationScoped
public static class CustomFilters {

@ServerRequestFilter(nonBlocking = true, priority = Priorities.USER + 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Priorities;
Expand Down Expand Up @@ -134,6 +135,7 @@ public Uni<Void> uniResponseFilter(ContainerResponseContext ctx) {
}
}

@Singleton
public static class AlwaysEnabledFilter {

@ServerRequestFilter(priority = Priorities.USER + 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,10 @@ private FieldDescriptor generateConstructorAndDelegateField(ClassCreator cc, Cla
*/
private ScopeInspectionResult inspectScope(ClassInfo classInfo) {
if (classInfo.hasDeclaredAnnotation(ApplicationScoped.class) || classInfo.hasDeclaredAnnotation(RequestScoped.class)) {
return new ScopeInspectionResult(null, true);
return new ScopeInspectionResult(ApplicationScoped.class, true);
}
if (classInfo.hasDeclaredAnnotation(Singleton.class)) {
return new ScopeInspectionResult(null, false);
return new ScopeInspectionResult(Singleton.class, false);
}
List<FieldInfo> fields = classInfo.fields();
if (fields.isEmpty()) {
Expand Down

0 comments on commit 9fc44a4

Please sign in to comment.