Skip to content

Commit

Permalink
Merge pull request #2046 from yaohui-wyh/master
Browse files Browse the repository at this point in the history
Fix arrayIndexOutOfBounds exception for overloaded addModelMap method
  • Loading branch information
k8s-ci-robot authored Dec 24, 2021
2 parents d03c36a + 482b2b7 commit 621e23d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions util/src/main/java/io/kubernetes/client/util/ModelMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ public class ModelMapper {
@Deprecated
public static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz) {
String[] parts = apiGroupVersion.split("/");
if (parts.length == 1) { // legacy api group
if (parts.length <= 1) { // legacy api group
addModelMap("", apiGroupVersion, kind, clazz);
} else {
addModelMap(parts[0], parts[1], kind, clazz);
}
addModelMap(parts[0], parts[1], kind, clazz);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public void testAddingModel() {

assertNull(ModelMapper.getApiTypeClass("example.io/v1", "Tofu"));
assertNull(ModelMapper.getApiTypeClass("example.io", "v1", "Tofu"));

assertNull(ModelMapper.getApiTypeClass("v1", "Togu"));
ModelMapper.addModelMap("v1", "Togu", objClass);
assertEquals(objClass, ModelMapper.getApiTypeClass("", "v1", "Togu"));
assertEquals(objClass, ModelMapper.getApiTypeClass("v1", "Togu"));
}

@Test
Expand Down

0 comments on commit 621e23d

Please sign in to comment.