From b914623cf2a27ae7cc92b3528111e9415becc6f2 Mon Sep 17 00:00:00 2001 From: Szymon Sasin Date: Mon, 26 Aug 2024 16:00:16 +0300 Subject: [PATCH] fix --- .../main/java/com/mbed/coap/server/CoapServerBuilder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coap-core/src/main/java/com/mbed/coap/server/CoapServerBuilder.java b/coap-core/src/main/java/com/mbed/coap/server/CoapServerBuilder.java index 539db44b..670cd45d 100644 --- a/coap-core/src/main/java/com/mbed/coap/server/CoapServerBuilder.java +++ b/coap-core/src/main/java/com/mbed/coap/server/CoapServerBuilder.java @@ -138,10 +138,10 @@ public CoapServerBuilder maxIncomingBlockTransferSize(int size) { } private PutOnlyMap getOrCreateDuplicateDetectorCache(ScheduledExecutorService scheduledExecutorService) { - if (duplicateDetectionCache == null) { - duplicateDetectionCache = new DefaultDuplicateDetectorCache("Default cache", duplicationMaxSize, scheduledExecutorService); + if (duplicateDetectionCache != null) { + return duplicateDetectionCache; } - return duplicateDetectionCache; + return new DefaultDuplicateDetectorCache("Default cache", duplicationMaxSize, scheduledExecutorService); } private CapabilitiesResolver capabilities() { @@ -208,7 +208,7 @@ public CoapServerBuilder requestTagSupplier(RequestTagSupplier requestTagSupplie } public CoapServer build() { - requireNonNull(coapTransport, "Missing transport"); + CoapTransport coapTransport = requireNonNull(this.coapTransport, "Missing transport"); final boolean stopExecutor = scheduledExecutorService == null; final ScheduledExecutorService effectiveExecutorService = scheduledExecutorService != null ? scheduledExecutorService : Executors.newSingleThreadScheduledExecutor(); Timer timer = toTimer(effectiveExecutorService);