You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicenumMyKubeTypeHandler {
// these workPOD(Pod.class, KubernetesClient::pods),
DEPLOYMENT(Deployment.class, client -> client.apps().deployments()),
......
// this DOES NOT work due to unhandled `NullPointerException`CALICO_GLOBAL_NETWORK_POLICY(GlobalNetworkPolicy.class, client -> client.resources(GlobalNetworkPolicy.class));
......
publicNonNamespaceOperation<
HasMetadata,
KubernetesResourceList<? extendsHasMetadata>,
? extendsResource<HasMetadata>>
withAllNamespaces(KubernetesClientclient) {
// This is where it failedreturnthis.ops.apply(apiClient);
}
}
The stack trace is as follow
java.lang.NullPointerException: null
at io.fabric8.kubernetes.client.utils.KubernetesResourceUtil.loadRelated(KubernetesResourceUtil.java:415)
at io.fabric8.kubernetes.client.utils.KubernetesResourceUtil.inferListType(KubernetesResourceUtil.java:406)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl.<init>(HasMetadataOperationsImpl.java:50)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl.<init>(HasMetadataOperationsImpl.java:38)
at io.fabric8.kubernetes.client.BaseClient.newHasMetadataOperation(BaseClient.java:288)
at io.fabric8.kubernetes.client.BaseClient.resources(BaseClient.java:279)
at io.fabric8.kubernetes.client.Client.resources(Client.java:162)
at io.fabric8.kubernetes.client.KubernetesClient.resources(KubernetesClient.java:140)
at com.foo.bar.kube.MyKubeTypeHandler.lambda$static$6(MyKubeTypeHandler.java:61)
Java version
$ java -version
Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/pki/ca-trust/extracted/java/cacerts
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment Temurin-11.0.17+8 (build 11.0.17+8)
OpenJDK 64-Bit Server VM Temurin-11.0.17+8 (build 11.0.17+8, mixed mode)
Fabric8 source code
When digging into the source code of fabric8 this is where I found that threw the NullPointerExceptions
After checking the java 11 docs for getContextClassLoader method, it could return null, which makes the subsequent method invocation, loadClass() from a null object.
I checked the latest code (1a3b2b6) that this unhandled NullPointerException issue may still exists.
My suggestion is simply expect and handle the NullPointerException in the catch clause, as in #4792
Describe the bug
Background
Hi, I am working on the Calico GlobalNetworkPolicy CRD with Fabric8
6.0.0
. After generating the Java classes from the CRD YAML with the java-generator-maven-plugin and manually fixed the namespaced issue, I always gotNullPointerException
when I try withThe stack trace is as follow
Java version
$ java -version Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/pki/ca-trust/extracted/java/cacerts openjdk version "11.0.17" 2022-10-18 OpenJDK Runtime Environment Temurin-11.0.17+8 (build 11.0.17+8) OpenJDK 64-Bit Server VM Temurin-11.0.17+8 (build 11.0.17+8, mixed mode)
Fabric8 source code
When digging into the source code of fabric8 this is where I found that threw the
NullPointerException
sProposal
After checking the java 11 docs for
getContextClassLoader
method, it could returnnull
, which makes the subsequent method invocation,loadClass()
from a null object.I checked the latest code (1a3b2b6) that this unhandled
NullPointerException
issue may still exists.My suggestion is simply expect and handle the
NullPointerException
in thecatch
clause, as in #4792Fabric8 Kubernetes Client version
6.0.0
Steps to reproduce
openjdk 11.0.17
GlobalNetworkPolicy
from the Calico GlobalNetworkPolicy CRD.Expected behavior
The
NullPointerException
should be expected and handled.Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.24
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: