Skip to content

Commit

Permalink
Arc - additional requested minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Apr 11, 2023
1 parent ca945b1 commit 259ef94
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1038,10 +1038,10 @@ private List<BeanInfo> findBeans(Collection<DotName> beanDefiningAnnotations, Li
if (annotationStore.hasAnnotation(method, DotNames.OBSERVES)) {
syncObserverMethods.computeIfAbsent(method, ignored -> new HashSet<>())
.add(beanClass);
// add only concrete classes
if (!Modifier.isAbstract(beanClass.flags())) {
// do not register classes with observers and no bean def. annotation as beans in strict mode
if (!strictCompatibility) {
// add only concrete classes
beanClasses.add(beanClass);
if (!hasBeanDefiningAnnotation) {
LOGGER.debugf(
Expand All @@ -1053,10 +1053,10 @@ private List<BeanInfo> findBeans(Collection<DotName> beanDefiningAnnotations, Li
} else if (annotationStore.hasAnnotation(method, DotNames.OBSERVES_ASYNC)) {
asyncObserverMethods.computeIfAbsent(method, ignored -> new HashSet<>())
.add(beanClass);
// add only concrete classes
if (!Modifier.isAbstract(beanClass.flags())) {
// do not register classes with observers and no bean def. annotation as beans in strict mode
if (!strictCompatibility) {
// add only concrete classes
beanClasses.add(beanClass);
if (!hasBeanDefiningAnnotation) {
LOGGER.debugf(
Expand All @@ -1080,12 +1080,19 @@ private List<BeanInfo> findBeans(Collection<DotName> beanDefiningAnnotations, Li
if (annotationStore.hasAnnotation(field, DotNames.INJECT)) {
throw new DefinitionException("Injected field cannot be annotated with @Produces: " + field);
}
// Do not register classes with producers and no bean def. annotation as beans in strict mode
// Producer fields are not inherited
producerFields.add(field);
if (!hasBeanDefiningAnnotation) {
LOGGER.debugf("Producer field found but %s has no bean defining annotation - using @Dependent",
beanClass);
beanClasses.add(beanClass);
if (strictCompatibility) {
if (hasBeanDefiningAnnotation) {
producerFields.add(field);
}
} else {
producerFields.add(field);
if (!hasBeanDefiningAnnotation) {
LOGGER.debugf("Producer field found but %s has no bean defining annotation - using @Dependent",
beanClass);
beanClasses.add(beanClass);
}
}
} else {
// Verify that non-producer fields are not annotated with stereotypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class Arc {
* @return {@link ArcContainer} instance with default configuration
*/
public static ArcContainer initialize() {
return initialize(ArcInitConfig.INSTANCE);
return initialize(ArcInitConfig.DEFAULT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public final class ArcInitConfig {
/**
* Basic instance without any configuration, all values are default
*/
public static final ArcInitConfig INSTANCE = builder().build();
public static final ArcInitConfig DEFAULT = builder().build();

/**
* Obtains a builder for {@link ArcInitConfig}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.quarkus.arc.tck.porting;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.context.spi.Context;
Expand All @@ -17,8 +17,8 @@

public class ContextsImpl implements Contexts<Context> {

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

@Override
public void setActive(Context context) {
Expand Down

0 comments on commit 259ef94

Please sign in to comment.