-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the bug
throw NullPointerException when Config.defaultClient()
** Client Version **
8.0.2
** Kubernetes Version **
v1.18.10
** Java Version **
Java 8
To Reproduce
use this kubeconfig, then run
Config.defaultClient();
Expected behavior
runs normally or If it's a Config format error, tell it's a Config format error, not a NullPointerException
KubeConfig
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxxxxxxx
server: https://xx.xx.xx.xx/k8s/clusters/c-mzvvs
name: dev03
contexts: null
current-context: dev03
kind: Config
preferences: {}
users:
- name: dev03
user:
token: xx.xx
Server (please complete the following information):
- Linux
- container
Additional context
cause
kubeconfig parse currentCluster is null,The code does not make a null pointer judgment
error log
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.xx.gateway.autoload.AutoLoadConfig$$EnhancerBySpringCGLIB$$27d9f98a]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:217)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1310)
... 16 common frames omitted
Caused by: java.lang.NullPointerException: null
at io.kubernetes.client.util.ClientBuilder.kubeconfig(ClientBuilder.java:245)
at io.kubernetes.client.util.ClientBuilder.getClientBuilder(ClientBuilder.java:114)
at io.kubernetes.client.util.ClientBuilder.standard(ClientBuilder.java:93)
at io.kubernetes.client.util.ClientBuilder.standard(ClientBuilder.java:85)
at io.kubernetes.client.util.Config.defaultClient(Config.java:113)
at net.xx.gateway.autoload.AutoLoadConfig.(AutoLoadConfig.java:56)
at net.xx.gateway.autoload.AutoLoadConfig$$EnhancerBySpringCGLIB$$27d9f98a.()
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:204)
... 18 common frames omitted