-
Notifications
You must be signed in to change notification settings - Fork 192
Closed
Description
Expected Behavior
When workers-auto-discovery is configured and @Profile annotation is used on top of @WorkflowImpl, if the profile condition doesn't match, the workflow should not be used.
Actual Behavior
Regardless of the condition in @Profile all classes annotated with @WorkflowImpl will be used.
Steps to Reproduce the Problem
- Create a workflow and its implementation SomeWorkflowImpl
- Annotate SomeWorkflowImpl with
@WorkflowImpland@Profile("!local") - Run the application with
localspring profile. The SomeWorkflowImpl can still be discovered and workers will be created.
Specifications
- Version: temporal-spring-boot-autoconfigure-alpha-1.18.2.jar
- Platform: mac
Some investigations
ClassPathScanningCandidateComponentProvider is used to scan the package to find workflows.
private Collection<Class<?>> autoDiscoverWorkflowImplementations() {
ClassPathScanningCandidateComponentProvider scanner =
new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(WorkflowImpl.class));
Set<Class<?>> implementations = new HashSet<>();
for (String pckg : properties.getWorkersAutoDiscovery().getPackages()) {
Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(pckg);
for (BeanDefinition beanDefinition : candidateComponents) {
try {
implementations.add(Class.forName(beanDefinition.getBeanClassName()));
} catch (ClassNotFoundException e) {
throw new BeanDefinitionValidationException(
"Fail loading class for bean definition " + beanDefinition, e);
}
}
}
return implementations;
}
But it seems the Environment is not passed in. According to spring doc
The Environment is need to evaluate @Conditional annotations.

Metadata
Metadata
Assignees
Labels
No labels