Apache Curator NPE in JsonInstanceSerializer

…衆ロ難τιáo~ 提交于 2019-12-07 16:10:37

问题


I am facing a strange NPE when starting Apache Curator's ServiceProvider. This happens intermittently on the servers, but I was not able to reproduce the error locally, that's why it's so difficult to know what's the problem.

Here's the code:

CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(zookeeperConnectString, new RetryNTimes(5, 1000));
curatorFramework.start();
ServiceDiscovery<Void> serviceDiscovery = ServiceDiscoveryBuilder.builder(Void.class).basePath(ZK_BASE_PATH).client(curatorFramework).build();
serviceDiscovery.start();
ServiceProvider<Void> serviceProvider = serviceDiscovery.serviceProviderBuilder().serviceName(ZK_SERVICE_NAME).build();
serviceProvider.start();

Here's the stack trace:

Caused by: java.lang.NullPointerException
at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:604)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1973)
at org.apache.curator.x.discovery.details.JsonInstanceSerializer.deserialize(JsonInstanceSerializer.java:50)
at org.apache.curator.x.discovery.details.ServiceCacheImpl.addInstance(ServiceCacheImpl.java:193)
at org.apache.curator.x.discovery.details.ServiceCacheImpl.start(ServiceCacheImpl.java:96)
at org.apache.curator.x.discovery.details.ServiceProviderImpl.start(ServiceProviderImpl.java:67)

What is happening is that in ServiceCacheImpl#addInstance a call to childData.getData() is returning null, and passing it to be deserialized, what obviously causes the NPE.

I'm using Apache Curator version 2.11.0.

Has anyone else faced the same issue? Thanks!

来源:https://stackoverflow.com/questions/42007102/apache-curator-npe-in-jsoninstanceserializer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!