diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeDeploymentManager.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeDeploymentManager.java index b5734722de63a..e54ec2d0ff057 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeDeploymentManager.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeDeploymentManager.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.TreeMap; import java.util.concurrent.Executor; +import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -141,22 +142,28 @@ public BeanFactory.BeanInstance apply(Class aClass) { } Map> mappersByMethod = new RuntimeMappingDeployment(templates) .buildClassMapper(); - mappersByMethod.forEach((method, mapper) -> { - for (RequestMapper.RequestPath path : mapper.getTemplates()) { - if ((clazz.getIsDisabled() != null) && clazz.getIsDisabled().get()) { - String templateWithoutSlash = path.template.template.startsWith("/") - ? path.template.template.substring(1) - : path.template.template; - String fullPath = clazz.getPath().endsWith("/") ? finalPrefix + clazz.getPath() + templateWithoutSlash - : finalPrefix + clazz.getPath() + "/" + templateWithoutSlash; - if (!disabledEndpoints.containsKey(fullPath)) { - disabledEndpoints.put(fullPath, new ArrayList<>()); + boolean isResourceClassDisabled = (clazz.getIsDisabled() != null) && clazz.getIsDisabled().get(); + mappersByMethod.forEach(new BiConsumer<>() { + @Override + public void accept(String method, RequestMapper mapper) { + for (int i = 0; i < mapper.getTemplates().size(); i++) { + RequestMapper.RequestPath path = mapper.getTemplates().get(i); + if (isResourceClassDisabled) { + String templateWithoutSlash = path.template.template.startsWith("/") + ? path.template.template.substring(1) + : path.template.template; + String fullPath = clazz.getPath().endsWith("/") + ? finalPrefix + clazz.getPath() + templateWithoutSlash + : finalPrefix + clazz.getPath() + "/" + templateWithoutSlash; + if (!disabledEndpoints.containsKey(fullPath)) { + disabledEndpoints.put(fullPath, new ArrayList<>()); + } + disabledEndpoints.get(fullPath).add(method); } - disabledEndpoints.get(fullPath).add(method); } } }); - if ((clazz.getIsDisabled() != null) && clazz.getIsDisabled().get()) { + if (isResourceClassDisabled) { continue; } resourceLocatorHandler.addResource(loadClass(clazz.getClassName()), mappersByMethod); @@ -259,7 +266,6 @@ private void addRuntimeConfigurableHandlers(RuntimeResource runtimeResource, } } - //TODO: this needs plenty more work to support all possible types and provide all information the FeatureContext allows private ConfigurationImpl configureFeatures(Features features, ResourceInterceptors interceptors, RuntimeExceptionMapper exceptionMapping) { @@ -271,7 +277,8 @@ private ConfigurationImpl configureFeatures(Features features, ResourceIntercept FeatureContextImpl featureContext = new FeatureContextImpl(interceptors, exceptionMapping, configuration, info.getFactoryCreator()); List resourceFeatures = features.getResourceFeatures(); - for (ResourceFeature resourceFeature : resourceFeatures) { + for (int i = 0; i < resourceFeatures.size(); i++) { + ResourceFeature resourceFeature = resourceFeatures.get(i); Feature feature = resourceFeature.getFactory().createInstance().getInstance(); boolean enabled = feature.configure(featureContext); if (enabled) { diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/DynamicFeatures.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/DynamicFeatures.java index fc75b35d05289..15fe5be02cd45 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/DynamicFeatures.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/DynamicFeatures.java @@ -25,9 +25,10 @@ public List getResourceDynamicFeatures() { } public void initializeDefaultFactories(Function> factoryCreator) { - for (ResourceDynamicFeature i : resourceDynamicFeatures) { - if (i.getFactory() == null) { - i.setFactory((BeanFactory) factoryCreator.apply(i.getClassName())); + for (int i = 0; i < resourceDynamicFeatures.size(); i++) { + ResourceDynamicFeature resourceFeature = resourceDynamicFeatures.get(i); + if (resourceFeature.getFactory() == null) { + resourceFeature.setFactory((BeanFactory) factoryCreator.apply(resourceFeature.getClassName())); } } } diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/Features.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/Features.java index a8fbfc3cd476d..9f136384d4bc1 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/Features.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/model/Features.java @@ -22,9 +22,10 @@ public List getResourceFeatures() { } public void initializeDefaultFactories(Function> factoryCreator) { - for (ResourceFeature i : resourceFeatures) { - if (i.getFactory() == null) { - i.setFactory((BeanFactory) factoryCreator.apply(i.getClassName())); + for (int i = 0; i < resourceFeatures.size(); i++) { + ResourceFeature resourceFeature = resourceFeatures.get(i); + if (resourceFeature.getFactory() == null) { + resourceFeature.setFactory((BeanFactory) factoryCreator.apply(resourceFeature.getClassName())); } } }