eclipse-californium / californium

CoAP/DTLS Java Implementation
https://www.eclipse.org/californium/
Other
730 stars 367 forks source link

Missing observe option causes NullPointerException #175

Closed boaks closed 7 years ago

boaks commented 7 years ago
public Observation(final Request request, final CorrelationContext context) {

    if (request == null) {
        throw new NullPointerException("request must not be null");
    } else if (request.getOptions().getObserve() != 0) {
        throw new IllegalArgumentException("request has no observe=0 option");
    }
    this.request = request;
    this.context = context;
}

java.lang.NullPointerException at org.eclipse.leshan.server.californium.impl.InMemoryLwM2mObservationStoreTest.newObservation(InMemoryLwM2mObservationStoreTest.java:98) at org.eclipse.leshan.server.californium.impl.InMemoryLwM2mObservationStoreTest.newObservation(InMemoryLwM2mObservationStoreTest.java:88) at org.eclipse.leshan.server.californium.impl.InMemoryLwM2mObservationStoreTest.remove_by_registrationId(InMemoryLwM2mObservationStoreTest.java:78)

I would guess, the unboxing will cause the NullPointerException.

Add a

boaks commented 7 years ago

I will first fix the leshan tests. This seems for me to be not very important.

sophokles73 commented 7 years ago

Fixed on 2.0.x in 71b11eaf886812e39872a6d96d3a4895200e9c8b