From e1418f4c731006af3d0f6a96b561014532a0a65d Mon Sep 17 00:00:00 2001 From: Hannes Date: Mon, 13 Jan 2025 16:38:38 +0100 Subject: [PATCH 1/2] Update BridgeHttpImpl.java --- .../edge/bridge/http/BridgeHttpImpl.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java b/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java index 460236c183c..a98ac2e3a7d 100644 --- a/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java +++ b/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java @@ -229,12 +229,10 @@ private void handleEvent(Event event) { final var item = this.cycleEndpoints.poll(); synchronized (item) { if (item.isRunning()) { - this.log.info( - "Process for " + item.cycleEndpoint + " is still running. Task is not queued twice"); - if (!this.cycleEndpoints.offer(item.resetTo(1))) { - this.log.info("Unable to re-add " + item + " to queue again."); - } - continue; + + if (!this.cycleEndpoints.offer(item.resetTo(1))) + + continue; } item.setRunning(true); @@ -298,14 +296,19 @@ private Runnable createTask(TimeEndpointCountdown endpointCountdown) { nextDelay = endpointCountdown.getTimeEndpoint().delayTimeProvider().onSuccessRunDelay(result); } - // TODO change in java 21 to switch case - if (nextDelay instanceof Delay.InfiniteDelay) { + switch (nextDelay) { + case Delay.InfiniteDelay infiniteDelay -> { // do not queue again return; - } else if (nextDelay instanceof Delay.DurationDelay durationDelay) { + } + case Delay.DurationDelay durationDelay -> { final var future = this.pool.schedule(this.createTask(endpointCountdown), durationDelay); endpointCountdown.setShutdownCurrentTask(() -> future.cancel(false)); } + default -> { + this.log.warn("Unhandled Delay type: " + nextDelay.getClass().getName()); + } + } } catch (Exception e) { if (this.pool.isShutdown()) { @@ -334,5 +337,4 @@ public Collection removeCycleEndpointIf(Predicate .map(CycleEndpointCountdown::getCycleEndpoint) // .toList(); } - } From 99a93fe0b1bd9c6020a0ec099ddce4a6bc207b6b Mon Sep 17 00:00:00 2001 From: Hannes Date: Mon, 13 Jan 2025 17:06:40 +0100 Subject: [PATCH 2/2] Fix BridgeHttpImpl.java --- .../src/io/openems/edge/bridge/http/BridgeHttpImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java b/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java index a98ac2e3a7d..3725194c435 100644 --- a/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java +++ b/io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java @@ -229,10 +229,10 @@ private void handleEvent(Event event) { final var item = this.cycleEndpoints.poll(); synchronized (item) { if (item.isRunning()) { - - if (!this.cycleEndpoints.offer(item.resetTo(1))) - - continue; + if (!this.cycleEndpoints.offer(item.resetTo(1))) { + this.log.warn("Unable to re-add " + item + " to queue again."); + } + continue; } item.setRunning(true);