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

Avoid double caching by calling Application methods in ResourceConfig #3340

Merged
merged 1 commit into from
Sep 1, 2021
Merged
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 @@ -89,8 +89,6 @@ public InjectionManager create(Object parent) {
static class HelidonInjectionManager implements InjectionManager {
private static final Logger LOGGER = Logger.getLogger(HelidonInjectionManager.class.getName());

private Set<Class<?>> classes;
private Set<Object> singletons;
private final ResourceConfig resourceConfig;
private final InjectionManager shared;
private final InjectionManager forApplication;
Expand Down Expand Up @@ -261,33 +259,23 @@ public void preDestroy(Object preDestroyMe) {
}

/**
* Calls {@code getClasses} method and caches the result.
* Calls {@code getClasses} method in resource config.
*
* @return set of classes returned from {@code Application} object.
*/
private Set<Class<?>> getClasses() {
if (classes == null) {
Application application = resourceConfig.getApplication();
if (application != null) {
classes = application.getClasses();
}
}
return classes != null ? classes : Collections.emptySet();
Application application = resourceConfig.getApplication();
return application != null ? resourceConfig.getClasses() : Collections.emptySet();
}

/**
* Calls {@code getSingletons} method and caches the result.
* Calls {@code getSingletons} method in resource config.
*
* @return set of singletons returned from {@code Application} object.
*/
private Set<Object> getSingletons() {
if (singletons == null) {
Application application = resourceConfig.getApplication();
if (application != null) {
singletons = application.getSingletons();
}
}
return singletons != null ? singletons : Collections.emptySet();
Application application = resourceConfig.getApplication();
return application != null ? resourceConfig.getSingletons() : Collections.emptySet();
}

/**
Expand Down