Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge: Simplify Logging and Implement Java 21 Switch Pattern Matching in BridgeHttpImpl #2964

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@
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.");
this.log.warn("Unable to re-add " + item + " to queue again.");

Check warning on line 233 in io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java

View check run for this annotation

Codecov / codecov/patch

io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java#L233

Added line #L233 was not covered by tests
}
continue;
}
Expand Down Expand Up @@ -298,14 +296,19 @@
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 -> {

Check warning on line 300 in io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java

View check run for this annotation

Codecov / codecov/patch

io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java#L300

Added line #L300 was not covered by tests
// 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());

Check warning on line 309 in io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java

View check run for this annotation

Codecov / codecov/patch

io.openems.edge.bridge.http/src/io/openems/edge/bridge/http/BridgeHttpImpl.java#L309

Added line #L309 was not covered by tests
}
}

} catch (Exception e) {
if (this.pool.isShutdown()) {
Expand Down Expand Up @@ -334,5 +337,4 @@
.map(CycleEndpointCountdown::getCycleEndpoint) //
.toList();
}

}
Loading