diff --git a/leshan-core-cf/src/main/java/org/eclipse/leshan/core/californium/CoapAsyncRequestObserver.java b/leshan-core-cf/src/main/java/org/eclipse/leshan/core/californium/CoapAsyncRequestObserver.java index 646d1b7e8a..79760792a5 100644 --- a/leshan-core-cf/src/main/java/org/eclipse/leshan/core/californium/CoapAsyncRequestObserver.java +++ b/leshan-core-cf/src/main/java/org/eclipse/leshan/core/californium/CoapAsyncRequestObserver.java @@ -104,13 +104,16 @@ public void onSendError(Throwable error) { private synchronized void scheduleCleaningTask() { if (!cancelled) - cleaningTask = getExecutor().schedule(new Runnable() { - @Override - public void run() { - responseTimedOut.set(true); - coapRequest.cancel(); - } - }, timeoutInMs, TimeUnit.MILLISECONDS); + if (cleaningTask == null) { + LOG.trace("Schedule Cleaning Task for {}", coapRequest); + cleaningTask = getExecutor().schedule(new Runnable() { + @Override + public void run() { + responseTimedOut.set(true); + coapRequest.cancel(); + } + }, timeoutInMs, TimeUnit.MILLISECONDS); + } } private synchronized void cancelCleaningTask() {