Skip to content

Commit 259ef94

Browse files
committed
Arc - additional requested minor changes
1 parent ca945b1 commit 259ef94

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,10 @@ private List<BeanInfo> findBeans(Collection<DotName> beanDefiningAnnotations, Li
10381038
if (annotationStore.hasAnnotation(method, DotNames.OBSERVES)) {
10391039
syncObserverMethods.computeIfAbsent(method, ignored -> new HashSet<>())
10401040
.add(beanClass);
1041+
// add only concrete classes
10411042
if (!Modifier.isAbstract(beanClass.flags())) {
10421043
// do not register classes with observers and no bean def. annotation as beans in strict mode
10431044
if (!strictCompatibility) {
1044-
// add only concrete classes
10451045
beanClasses.add(beanClass);
10461046
if (!hasBeanDefiningAnnotation) {
10471047
LOGGER.debugf(
@@ -1053,10 +1053,10 @@ private List<BeanInfo> findBeans(Collection<DotName> beanDefiningAnnotations, Li
10531053
} else if (annotationStore.hasAnnotation(method, DotNames.OBSERVES_ASYNC)) {
10541054
asyncObserverMethods.computeIfAbsent(method, ignored -> new HashSet<>())
10551055
.add(beanClass);
1056+
// add only concrete classes
10561057
if (!Modifier.isAbstract(beanClass.flags())) {
10571058
// do not register classes with observers and no bean def. annotation as beans in strict mode
10581059
if (!strictCompatibility) {
1059-
// add only concrete classes
10601060
beanClasses.add(beanClass);
10611061
if (!hasBeanDefiningAnnotation) {
10621062
LOGGER.debugf(
@@ -1080,12 +1080,19 @@ private List<BeanInfo> findBeans(Collection<DotName> beanDefiningAnnotations, Li
10801080
if (annotationStore.hasAnnotation(field, DotNames.INJECT)) {
10811081
throw new DefinitionException("Injected field cannot be annotated with @Produces: " + field);
10821082
}
1083+
// Do not register classes with producers and no bean def. annotation as beans in strict mode
10831084
// Producer fields are not inherited
1084-
producerFields.add(field);
1085-
if (!hasBeanDefiningAnnotation) {
1086-
LOGGER.debugf("Producer field found but %s has no bean defining annotation - using @Dependent",
1087-
beanClass);
1088-
beanClasses.add(beanClass);
1085+
if (strictCompatibility) {
1086+
if (hasBeanDefiningAnnotation) {
1087+
producerFields.add(field);
1088+
}
1089+
} else {
1090+
producerFields.add(field);
1091+
if (!hasBeanDefiningAnnotation) {
1092+
LOGGER.debugf("Producer field found but %s has no bean defining annotation - using @Dependent",
1093+
beanClass);
1094+
beanClasses.add(beanClass);
1095+
}
10891096
}
10901097
} else {
10911098
// Verify that non-producer fields are not annotated with stereotypes

independent-projects/arc/runtime/src/main/java/io/quarkus/arc/Arc.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class Arc {
1919
* @return {@link ArcContainer} instance with default configuration
2020
*/
2121
public static ArcContainer initialize() {
22-
return initialize(ArcInitConfig.INSTANCE);
22+
return initialize(ArcInitConfig.DEFAULT);
2323
}
2424

2525
/**

independent-projects/arc/runtime/src/main/java/io/quarkus/arc/ArcInitConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public final class ArcInitConfig {
1010
/**
1111
* Basic instance without any configuration, all values are default
1212
*/
13-
public static final ArcInitConfig INSTANCE = builder().build();
13+
public static final ArcInitConfig DEFAULT = builder().build();
1414

1515
/**
1616
* Obtains a builder for {@link ArcInitConfig}

independent-projects/arc/tcks/cdi-tck-porting-pkg/src/main/java/io/quarkus/arc/tck/porting/ContextsImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.quarkus.arc.tck.porting;
22

33
import java.lang.annotation.Annotation;
4-
import java.util.HashMap;
54
import java.util.Map;
5+
import java.util.concurrent.ConcurrentHashMap;
66

77
import jakarta.enterprise.context.Dependent;
88
import jakarta.enterprise.context.spi.Context;
@@ -17,8 +17,8 @@
1717

1818
public class ContextsImpl implements Contexts<Context> {
1919

20-
// volatile is just a precaution in case some (future) TCK test attempts to use this in between multiple threads
21-
private volatile Map<Context, InjectableContext.ContextState> contextStateMap = new HashMap();
20+
// ConcurrentHashMap is just future-proofing, could be implemented with plain map too
21+
private final Map<Context, InjectableContext.ContextState> contextStateMap = new ConcurrentHashMap<>();
2222

2323
@Override
2424
public void setActive(Context context) {

0 commit comments

Comments
 (0)