diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.java index 273a6c31ba4..0970384e27f 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.java @@ -35,7 +35,6 @@ import io.fabric8.kubernetes.api.builder.Visitor; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; -import io.fabric8.kubernetes.api.model.KubernetesResource; import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.Handlers; @@ -52,7 +51,6 @@ import io.fabric8.kubernetes.client.dsl.VisitFromServerGetWatchDeleteRecreateWaitApplicable; import io.fabric8.kubernetes.client.dsl.Waitable; import io.fabric8.kubernetes.client.dsl.base.OperationSupport; -import io.fabric8.kubernetes.client.handlers.KubernetesListHandler; import io.fabric8.kubernetes.client.internal.readiness.Readiness; import okhttp3.OkHttpClient; @@ -304,12 +302,12 @@ private static HasMetadata asHasMetadata(T item) { throw new IllegalArgumentException("Item needs to be an instance of HasMetadata or String."); } - static ResourceHandler checkForHandlerOf(T item) { + static void checkForHandlerOf(T item) { if (item instanceof HasMetadata) { - return handlerOf((HasMetadata)item); - } else if (item instanceof KubernetesList) { - return new KubernetesListHandler(); - } else { + if (handlerOf((HasMetadata)item) == null) { + throw new KubernetesClientException("No handler found for object:" + item); + } + } else if (!(item instanceof KubernetesList)) { throw new IllegalArgumentException("Could not find a registered handler for item: [" + item + "]."); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodCrudTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodCrudTest.java index 904afb2d575..f432a916c6b 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodCrudTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodCrudTest.java @@ -93,11 +93,13 @@ void testCrud() { assertNotNull(pod); assertEquals(2, pod.getMetadata().getLabels().size()); - pod2 = client.pods().inNamespace("ns1").withName("pod2").edit(new Visitor() { + pod2 = client.pods().inNamespace("ns1").withName("pod2").edit(new Visitor() { @Override - public void visit(PodBuilder buidler) { - buidler.editMetadata().addToLabels("another", "one").endMetadata(); + public void visit(Object builder) { + if (builder instanceof PodBuilder) { + ((PodBuilder)builder).editMetadata().addToLabels("another", "one").endMetadata(); + } } });