From 18b81471417badece3cd5410a5b936c892f3acba Mon Sep 17 00:00:00 2001 From: Simon Bernard Date: Thu, 12 Sep 2024 11:49:52 +0200 Subject: [PATCH] GH-1649: Fix NPE, log warn message when no registration on notification. --- .../endpoint/CaliforniumServerEndpointsProvider.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/leshan-tl-cf-server-coap/src/main/java/org/eclipse/leshan/transport/californium/server/endpoint/CaliforniumServerEndpointsProvider.java b/leshan-tl-cf-server-coap/src/main/java/org/eclipse/leshan/transport/californium/server/endpoint/CaliforniumServerEndpointsProvider.java index f005b892c9..ea21de41e6 100644 --- a/leshan-tl-cf-server-coap/src/main/java/org/eclipse/leshan/transport/californium/server/endpoint/CaliforniumServerEndpointsProvider.java +++ b/leshan-tl-cf-server-coap/src/main/java/org/eclipse/leshan/transport/californium/server/endpoint/CaliforniumServerEndpointsProvider.java @@ -158,11 +158,20 @@ public void onNotification(Request coapRequest, Response coapResponse) { if (observation == null) { LOG.warn("Unexpected error: Unable to find observation with token {} for registration {}", coapResponse.getToken(), regid); + // We just log it because, this is probably caused by bad device behavior : + // https://github.com/eclipse-leshan/leshan/issues/1634 return; } // Get profile LwM2mPeer client = identityHandler.getIdentity(coapResponse); ClientProfile profile = toolbox.getProfileProvider().getProfile(client.getIdentity()); + if (profile == null) { + LOG.warn("Unexpected error: Unable to find registration with id {} for observation {}", + regid, coapResponse.getToken()); + // We just log it because, this is probably caused by bad device behavior : + // https://github.com/eclipse-leshan/leshan/issues/1634 + return; + } // create Observe Response try {