diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java index 5846b9e031517..a76826b77d638 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -239,6 +240,7 @@ void validateRuntimeConfigProperty( recorder.validateConfigProperties( configProperties.stream() .filter(ConfigPropertyBuildItem::isRuntimeInit) + .sorted(Comparator.comparing(ConfigPropertyBuildItem::getPropertyName)) .map(p -> configPropertyToConfigValidation(p, reflectiveClass)) .collect(toSet())); } diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeansProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeansProcessor.java index c34d1dca923b7..173e39cfbaea0 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeansProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeansProcessor.java @@ -1,8 +1,9 @@ package io.quarkus.arc.deployment; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -38,14 +39,20 @@ public class SyntheticBeansProcessor { void initStatic(ArcRecorder recorder, List syntheticBeans, BeanRegistrationPhaseBuildItem beanRegistration, BuildProducer configurators) { - Map, ?>> creationFunctions = new HashMap<>(); - Map> checkActiveSuppliers = new HashMap<>(); - + TreeMap sortedBeans = new TreeMap<>(); for (SyntheticBeanBuildItem bean : syntheticBeans) { if (bean.hasRecorderInstance() && bean.isStaticInit()) { - configureSyntheticBean(recorder, creationFunctions, checkActiveSuppliers, beanRegistration, bean); + sortedBeans.put(createName(bean.configurator()), bean); } } + + Map, ?>> creationFunctions = new LinkedHashMap<>(); + Map> checkActiveSuppliers = new LinkedHashMap<>(); + + for (Map.Entry entry : sortedBeans.entrySet()) { + configureSyntheticBean(recorder, entry.getKey(), creationFunctions, checkActiveSuppliers, beanRegistration, + entry.getValue()); + } // Init the map of bean instances recorder.initStaticSupplierBeans(creationFunctions, checkActiveSuppliers); } @@ -56,14 +63,20 @@ void initStatic(ArcRecorder recorder, List syntheticBean ServiceStartBuildItem initRuntime(ArcRecorder recorder, List syntheticBeans, BeanRegistrationPhaseBuildItem beanRegistration, BuildProducer configurators) { - Map, ?>> creationFunctions = new HashMap<>(); - Map> checkActiveSuppliers = new HashMap<>(); - + TreeMap sortedBeans = new TreeMap<>(); for (SyntheticBeanBuildItem bean : syntheticBeans) { if (bean.hasRecorderInstance() && !bean.isStaticInit()) { - configureSyntheticBean(recorder, creationFunctions, checkActiveSuppliers, beanRegistration, bean); + sortedBeans.put(createName(bean.configurator()), bean); } } + + Map, ?>> creationFunctions = new LinkedHashMap<>(); + Map> checkActiveSuppliers = new LinkedHashMap<>(); + + for (Map.Entry entry : sortedBeans.entrySet()) { + configureSyntheticBean(recorder, entry.getKey(), creationFunctions, checkActiveSuppliers, beanRegistration, + entry.getValue()); + } recorder.initRuntimeSupplierBeans(creationFunctions, checkActiveSuppliers); return new ServiceStartBuildItem("runtime-bean-init"); } @@ -72,18 +85,22 @@ ServiceStartBuildItem initRuntime(ArcRecorder recorder, List syntheticBeans, BeanRegistrationPhaseBuildItem beanRegistration, BuildProducer configurators) { + TreeMap sortedBeans = new TreeMap<>(); for (SyntheticBeanBuildItem bean : syntheticBeans) { if (!bean.hasRecorderInstance()) { - configureSyntheticBean(null, null, null, beanRegistration, bean); + sortedBeans.put(createName(bean.configurator()), bean); } } + + for (Map.Entry entry : sortedBeans.entrySet()) { + configureSyntheticBean(null, entry.getKey(), null, null, beanRegistration, entry.getValue()); + } } - private void configureSyntheticBean(ArcRecorder recorder, + private void configureSyntheticBean(ArcRecorder recorder, String name, Map, ?>> creationFunctions, Map> checkActiveSuppliers, BeanRegistrationPhaseBuildItem beanRegistration, SyntheticBeanBuildItem bean) { - String name = createName(bean.configurator()); if (bean.configurator().getRuntimeValue() != null) { creationFunctions.put(name, recorder.createFunction(bean.configurator().getRuntimeValue())); } else if (bean.configurator().getSupplier() != null) { diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ValueRegistryProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ValueRegistryProcessor.java index ad00b8553d427..1094118b58f69 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ValueRegistryProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ValueRegistryProcessor.java @@ -1,5 +1,6 @@ package io.quarkus.arc.deployment; +import java.util.Comparator; import java.util.HashSet; import java.util.ServiceLoader; import java.util.Set; @@ -42,7 +43,7 @@ void runtimeInfo( ValueRegistryRecorder recorder, BuildProducer syntheticBeans) { - for (Class runtimeInfo : getRuntimeInfoClasses()) { + for (Class runtimeInfo : getRuntimeInfoClasses().stream().sorted(Comparator.comparing(Class::getName)).toList()) { SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem .configure(runtimeInfo) .startup() diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java index d180df98108c3..6c7c8bc8ce51e 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java @@ -1338,8 +1338,9 @@ public BlockCreator checkActiveMethod() { .append(implClassName) .append("'\n"); msgBuilder.append("This bean is injected into:"); - for (InjectionPointInfo matchingIP : matchingIPs) { - msgBuilder.append("\n\t- ").append(matchingIP.getTargetInfo()); + for (String matchingTargetInfo : matchingIPs.stream().map(InjectionPointInfo::getTargetInfo).sorted() + .toList()) { + msgBuilder.append("\n\t- ").append(matchingTargetInfo); } } b1.throw_(InactiveBeanException.class, b1.exprToString(msg));