Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

package org.glassfish.jersey.inject.hk2;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;

Expand Down Expand Up @@ -194,11 +197,24 @@ public Injectee apply(CacheKey cacheKey) {
final Class<?> clazz = f.getType();
if (serviceLocator.getServiceHandle(clazz).getActiveDescriptor().getScopeAnnotation()
== RequestScoped.class) {
final AbstractActiveDescriptor<Object> descriptor =
BuilderHelper.activeLink(clazz)
.to(clazz)
.in(RequestScoped.class)
.build();
//to fix proxy issue from Singletons was needed to review if the injecteeClass contains
//Singleton annotation to indicate Singleton scope instead of Request
Optional<Annotation> optAnnotation =
Arrays.stream(injectee.getInjecteeClass().getAnnotations())
.filter(p -> p.annotationType().getName().equals("jakarta.ejb.Singleton"))
.findFirst();
AbstractActiveDescriptor<Object> descriptor;
if (optAnnotation.isPresent()) {
descriptor = BuilderHelper.activeLink(clazz)
.to(clazz)
.in(Singleton.class)
.build();
} else {
descriptor = BuilderHelper.activeLink(clazz)
.to(clazz)
.in(RequestScoped.class)
.build();
}
return new DescriptorOverridingInjectee(injectee, descriptor);
}
}
Expand Down