Github user cmckn commented on the issue:
https://github.com/apache/curator/pull/261
I realize this issue has been closed, but I'm still seeing unexpected
exceptions in some of my applications during `ServiceCacheImpl#start`.
The merged changes to address this added a null-check around calls to
`ServiceCacheImpl#addInstance` within `ServiceCacheImpl#start` (correct me if
this is wrong).
From what I've seen in my own apps, the issue is not caused by a `null`
`char[]` being passed to `ServiceCacheImpl#addInstance` -- it is caused by an
*empty* `char[]` being passed. This empty array causes a `NullPointerException`
to be thrown by my deserializer, or (if the empty case is handled there,
returning `null` from the deserializer) causes a `NullPointerException` when
the `null` instance is put in `instances` (a `ConcurrentMap`).
The implementation of `ServiceCacheImpl#addInstance` below is what resolved
things for me, patched into the `4.0.1` release. The `if` at the open of the
function is the only change. Just wanted to throw this out there, because I've
only been able to resolve the issue by using this patch -- no dice on the
current `master` branch. This patch doesn't appear to cause any issues, but I'm
not sure if the `cache.clearDataBytes...` call should be performed regardless
of whether or not the `byte[]` is empty (i.e. I'm not sure if bailing out of
the function at this particular step is appropriate or will have side-effects).
```
private void addInstance(ChildData childData, boolean onlyIfAbsent) throws
Exception
{
+ if( childData.getData() == null || childData.getData().length
== 0 )
+ {
+ return;
+ }
String instanceId = instanceIdFromData(childData);
ServiceInstance<T> serviceInstance =
discovery.getSerializer().deserialize(childData.getData());
if ( onlyIfAbsent )
{
instances.putIfAbsent(instanceId, serviceInstance);
}
else
{
instances.put(instanceId, serviceInstance);
}
cache.clearDataBytes(childData.getPath(),
childData.getStat().getVersion());
}
```
Happy to provide more information if needed.
---