eclipse-californium / californium.tools

Californium project
Other
59 stars 57 forks source link

cf-rd EndPoint Type never set #14

Closed calif-devel closed 8 years ago

calif-devel commented 8 years ago

When registering an endpoint by Posting rd?ep=abcdefg&et=my-device, I do get CREATED response. However when I do look up on resource rd-lookup/ep I see NPE in the logs.

19 SEVERE [CoapEndpoint$5]: Exception in protocol stage thread: null - (org.eclipse.californium.core.network.CoapEndpoint$5.java:697) run() in thread pool-1-thread-2 at (2015-12-25 23:42:23)
java.lang.NullPointerException
    at org.eclipse.californium.tools.resources.RDLookUpEPResource.handleGET(RDLookUpEPResource.java:77)
    at org.eclipse.californium.core.CoapResource.handleRequest(CoapResource.java:212)

That line # 77 in RDLookUpEPResource is checking to EndpointType, I don't see where EndpointType is ever set.

mkovatsc commented 8 years ago

Yes, I am already aware of this problem and have a fix. However, we want to find a good way to manage multiple version (stable 1.0.x and experimental 1.x.x). Thanks for raising this, though!

calif-devel commented 8 years ago

Is there something I can do to fix it? I was wondering in RDNodeResource#setParameters(Request) method, adding the following could be simple solution:

if (attr.getName().equals(LinkFormat.CONTEXT)){
...
}
if (attr.getName().equals(LinkFormat.END_POINT_TYPE)){
   setEndpointType(attr.getValue());
}
mkovatsc commented 8 years ago

Yes, you can add this for a local quick fix.

mkovatsc commented 8 years ago

Was fixed in c1ba87ef701463367c502cc5700fced72e8e3d24