Skip to content

Commit 4da87cc

Browse files
Spring boot: fail creation if duplicate definitions detected (#2511)
1 parent e5bb3a5 commit 4da87cc

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

temporal-spring-boot-autoconfigure/src/main/java/io/temporal/spring/boot/autoconfigure/properties/NamespaceProperties.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@ public class NamespaceProperties {
1515
private final @Nullable List<WorkerProperties> workers;
1616
private final @Nonnull String namespace;
1717
private final @Nullable WorkflowCacheProperties workflowCache;
18+
private final @Nullable Boolean ignoreDuplicateDefinitions;
1819

1920
@ConstructorBinding
2021
public NamespaceProperties(
2122
@Nullable String namespace,
2223
@Nullable WorkersAutoDiscoveryProperties workersAutoDiscovery,
2324
@Nullable List<WorkerProperties> workers,
24-
@Nullable WorkflowCacheProperties workflowCache) {
25+
@Nullable WorkflowCacheProperties workflowCache,
26+
@Nullable Boolean ignoreDuplicateDefinitions) {
2527
this.workersAutoDiscovery = workersAutoDiscovery;
2628
this.workers = workers;
2729
this.namespace = MoreObjects.firstNonNull(namespace, NAMESPACE_DEFAULT);
2830
this.workflowCache = workflowCache;
31+
this.ignoreDuplicateDefinitions =
32+
MoreObjects.firstNonNull(ignoreDuplicateDefinitions, Boolean.TRUE);
2933
}
3034

3135
@Nullable
@@ -51,6 +55,11 @@ public WorkflowCacheProperties getWorkflowCache() {
5155
return workflowCache;
5256
}
5357

58+
@Nonnull
59+
public Boolean isIgnoreDuplicateDefinitions() {
60+
return Boolean.TRUE;
61+
}
62+
5463
public static class WorkflowCacheProperties {
5564
private final @Nullable Integer maxInstances;
5665
private final @Nullable Integer maxThreads;

temporal-spring-boot-autoconfigure/src/main/java/io/temporal/spring/boot/autoconfigure/properties/NonRootNamespaceProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public NonRootNamespaceProperties(
4343
@Nullable List<WorkerProperties> workers,
4444
@Nullable WorkflowCacheProperties workflowCache,
4545
@Nullable ConnectionProperties connection,
46-
@Nullable Boolean startWorkers) {
47-
super(namespace, workersAutoDiscovery, workers, workflowCache);
46+
@Nullable Boolean startWorkers,
47+
@Nullable Boolean ignoreDuplicateDefinitions) {
48+
super(namespace, workersAutoDiscovery, workers, workflowCache, ignoreDuplicateDefinitions);
4849
this.alias = alias;
4950
this.connection = connection;
5051
this.startWorkers = startWorkers;

temporal-spring-boot-autoconfigure/src/main/java/io/temporal/spring/boot/autoconfigure/properties/TemporalProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public TemporalProperties(
2424
@Nullable WorkflowCacheProperties workflowCache,
2525
@Nonnull ConnectionProperties connection,
2626
@Nullable TestServerProperties testServer,
27-
@Nullable Boolean startWorkers) {
28-
super(namespace, workersAutoDiscovery, workers, workflowCache);
27+
@Nullable Boolean startWorkers,
28+
@Nullable Boolean ignoreDuplicateDefinitions) {
29+
super(namespace, workersAutoDiscovery, workers, workflowCache, ignoreDuplicateDefinitions);
2930
this.connection = connection;
3031
this.testServer = testServer;
3132
this.startWorkers = startWorkers;

temporal-spring-boot-autoconfigure/src/main/java/io/temporal/spring/boot/autoconfigure/template/WorkersTemplate.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ private void configureActivityImplementationAutoDiscovery(
432432
worker.getTaskQueue(),
433433
registeredEx.getRegisteredTypeName());
434434
}
435+
if (!namespaceProperties.isIgnoreDuplicateDefinitions()) {
436+
throw registeredEx;
437+
}
435438
}
436439
}
437440

@@ -468,6 +471,9 @@ private void configureNexusServiceImplementationAutoDiscovery(
468471
worker.getTaskQueue(),
469472
registeredEx.getRegisteredTypeName());
470473
}
474+
if (!namespaceProperties.isIgnoreDuplicateDefinitions()) {
475+
throw registeredEx;
476+
}
471477
}
472478
}
473479

@@ -492,6 +498,9 @@ private void configureWorkflowImplementationAutoDiscovery(
492498
worker.getTaskQueue(),
493499
registeredEx.getRegisteredTypeName());
494500
}
501+
if (!namespaceProperties.isIgnoreDuplicateDefinitions()) {
502+
throw registeredEx;
503+
}
495504
}
496505
}
497506

0 commit comments

Comments
 (0)