Skip to content

Commit 3080aa2

Browse files
committed
fix: off by one error
1 parent 770fe54 commit 3080aa2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static String getDefaultResourceControllerName(String rcControllerClassNa
4848
// if the name is fully qualified, extract the simple class name
4949
final var lastDot = rcControllerClassName.lastIndexOf('.');
5050
if (lastDot > 0) {
51-
rcControllerClassName = rcControllerClassName.substring(lastDot);
51+
rcControllerClassName = rcControllerClassName.substring(lastDot + 1);
5252
}
5353
return rcControllerClassName.toLowerCase(Locale.ROOT);
5454
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.javaoperatorsdk.operator;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import io.javaoperatorsdk.operator.sample.simple.TestCustomResourceController;
6+
import org.junit.jupiter.api.Test;
7+
8+
class ControllerUtilsTest {
9+
10+
@Test
11+
void getDefaultResourceControllerName() {
12+
assertEquals(
13+
"testcustomresourcecontroller",
14+
ControllerUtils.getDefaultResourceControllerName(
15+
TestCustomResourceController.class.getCanonicalName()));
16+
}
17+
}

0 commit comments

Comments
 (0)