Skip to content

Commit 59345b6

Browse files
author
Soroosh Sarabadani
committed
Update getFinalizer logic
1 parent b160d45 commit 59345b6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

operator-framework/src/main/java/io/javaoperatorsdk/operator/ControllerUtils.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,25 @@ public class ControllerUtils {
2424
private static Map<Class<? extends CustomResource>, Class<? extends CustomResourceDoneable<? extends CustomResource>>>
2525
doneableClassCache = new HashMap<>();
2626

27-
static String getDefaultFinalizer(ResourceController controller) {
28-
return getAnnotation(controller).finalizerName();
27+
static String getFinalizer(ResourceController controller) {
28+
final String annotationFinalizerName = getAnnotation(controller).finalizerName();
29+
final String finalizerName;
30+
if (Controller.NULL.equals(annotationFinalizerName)) {
31+
finalizerName = controller.getDefaultFinalizerName();
32+
if (finalizerName == null) {
33+
throw new IllegalStateException("Controller annotation cannot be used on Local, Anonymous or Hidden classes");
34+
}
35+
} else {
36+
finalizerName = annotationFinalizerName;
37+
}
38+
return finalizerName;
2939
}
3040

3141
static boolean getGenerationEventProcessing(ResourceController controller) {
3242
return getAnnotation(controller).generationAwareEventProcessing();
3343
}
3444

35-
static <R extends CustomResource> Class<R> getCustomResourceClass(ResourceController controller) {
45+
static <R extends CustomResource> Class<R> getCustomResourceClass(ResourceController<R> controller) {
3646
return (Class<R>) getAnnotation(controller).customResourceClass();
3747
}
3848

0 commit comments

Comments
 (0)