From df884ac64312d8146aa033ccc44a3a8997b865a5 Mon Sep 17 00:00:00 2001 From: Holger Friedrich Date: Sun, 31 Mar 2024 10:43:44 +0200 Subject: [PATCH] Upgrade SAT plugin to 0.16.0 (#16582) Modify code which leads to build error with new version of SpotBugs. Signed-off-by: Holger Friedrich --- .../openhab/binding/bluetooth/gattserial/GattSocket.java | 9 +++++---- .../govee/internal/readme/ThingTypeTableGenerator.java | 2 +- .../binding/freeboxos/internal/api/rest/HomeManager.java | 4 +++- .../binding/hue/internal/connection/Clip2Bridge.java | 4 ++-- .../mqtt/generic/mapping/MqttTopicClassMapperTests.java | 4 ++-- .../internal/discovery/ObjectPropertyRequest.java | 5 +++-- .../internal/rio/AbstractRioHandlerCallback.java | 2 +- .../internal/protocol/RemoteControllerLegacy.java | 2 +- .../handler/SpotifyDynamicStateDescriptionProvider.java | 7 ++++--- .../verisure/internal/handler/VerisureThingHandler.java | 3 ++- pom.xml | 2 +- 11 files changed, 25 insertions(+), 19 deletions(-) diff --git a/bundles/org.openhab.binding.bluetooth.govee/src/main/java/org/openhab/binding/bluetooth/gattserial/GattSocket.java b/bundles/org.openhab.binding.bluetooth.govee/src/main/java/org/openhab/binding/bluetooth/gattserial/GattSocket.java index d65b8d57f76..d8ed64c150c 100644 --- a/bundles/org.openhab.binding.bluetooth.govee/src/main/java/org/openhab/binding/bluetooth/gattserial/GattSocket.java +++ b/bundles/org.openhab.binding.bluetooth.govee/src/main/java/org/openhab/binding/bluetooth/gattserial/GattSocket.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -38,14 +39,14 @@ public abstract class GattSocket { private final Deque messageProcessors = new ConcurrentLinkedDeque<>(); - public void registerMessageHandler(MessageHandler messageHandler) { + public void registerMessageHandler(MessageHandler<@NonNull T, @NonNull R> messageHandler) { // we need to use a dummy future since ConcurrentHashMap doesn't allow null values messageProcessors.addFirst(new MessageProcessor(messageHandler, COMPLETED_FUTURE)); } protected abstract ScheduledExecutorService getScheduler(); - public void sendMessage(MessageServicer messageServicer) { + public void sendMessage(MessageServicer<@NonNull T, @NonNull R> messageServicer) { T message = messageServicer.createMessage(); CompletableFuture<@Nullable Void> messageFuture = sendMessage(message); @@ -106,10 +107,10 @@ public abstract class GattSocket { } private class MessageProcessor { - private MessageHandler messageHandler; + private MessageHandler<@NonNull T, @NonNull R> messageHandler; private Future timeoutFuture; - public MessageProcessor(MessageHandler messageHandler, Future timeoutFuture) { + public MessageProcessor(MessageHandler<@NonNull T, @NonNull R> messageHandler, Future timeoutFuture) { this.messageHandler = messageHandler; this.timeoutFuture = timeoutFuture; } diff --git a/bundles/org.openhab.binding.bluetooth.govee/src/test/java/org/openhab/binding/bluetooth/govee/internal/readme/ThingTypeTableGenerator.java b/bundles/org.openhab.binding.bluetooth.govee/src/test/java/org/openhab/binding/bluetooth/govee/internal/readme/ThingTypeTableGenerator.java index 691fe45e73c..5a51fbf7fa6 100644 --- a/bundles/org.openhab.binding.bluetooth.govee/src/test/java/org/openhab/binding/bluetooth/govee/internal/readme/ThingTypeTableGenerator.java +++ b/bundles/org.openhab.binding.bluetooth.govee/src/test/java/org/openhab/binding/bluetooth/govee/internal/readme/ThingTypeTableGenerator.java @@ -79,7 +79,7 @@ public class ThingTypeTableGenerator { // write actual rows rows.forEach(row -> { writer.append(writeRow(maxColumns, row, ' ')).append('\n'); - if (row == headerRow) { + if (headerRow.equals(row)) { writer.append(writeRow(maxColumns, new String[] { "", "", "" }, '-')).append('\n'); } }); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java index 4c5d226b1a7..2170a2fbdc5 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java @@ -17,6 +17,7 @@ import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.B import java.util.List; import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.freeboxos.internal.api.FreeboxException; @@ -167,7 +168,8 @@ public class HomeManager extends RestManager { } public boolean putCommand(int nodeId, int stateSignalId, T value) throws FreeboxException { - put(new EndpointValue<>(value), ENDPOINTS_PATH, String.valueOf(nodeId), String.valueOf(stateSignalId)); + put(new EndpointValue<@NonNull T>(value), ENDPOINTS_PATH, String.valueOf(nodeId), + String.valueOf(stateSignalId)); return true; } } diff --git a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/connection/Clip2Bridge.java b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/connection/Clip2Bridge.java index 2baf35ded7f..69d7fa67caa 100644 --- a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/connection/Clip2Bridge.java +++ b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/connection/Clip2Bridge.java @@ -396,7 +396,7 @@ public class Clip2Bridge implements Closeable { @Override public void onGoAway(@Nullable Session session, @Nullable GoAwayFrame frame) { Objects.requireNonNull(session); - if (http2Session == session) { + if (session.equals(http2Session)) { Thread recreateThread = new Thread(() -> recreateSession()); Clip2Bridge.this.recreateThread = recreateThread; recreateThread.start(); @@ -412,7 +412,7 @@ public class Clip2Bridge implements Closeable { public void onPing(@Nullable Session session, @Nullable PingFrame frame) { Objects.requireNonNull(session); Objects.requireNonNull(frame); - if (http2Session == session) { + if (session.equals(http2Session)) { checkAliveOk(); if (!frame.isReply()) { session.ping(new PingFrame(true), Callback.NOOP); diff --git a/bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/MqttTopicClassMapperTests.java b/bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/MqttTopicClassMapperTests.java index 65c5e3ae2a8..e0fe4edc705 100644 --- a/bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/MqttTopicClassMapperTests.java +++ b/bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/mapping/MqttTopicClassMapperTests.java @@ -221,8 +221,8 @@ public class MqttTopicClassMapperTests { "homie/device123", fieldChangedObserverMock, 10); assertThat(future.isDone(), is(true)); - SubscribeFieldToMQTTtopic field = attributes.subscriptions.stream().filter(f -> f.field.getName() == "state") - .findFirst().get(); + SubscribeFieldToMQTTtopic field = attributes.subscriptions.stream() + .filter(f -> "state".equals(f.field.getName())).findFirst().get(); field.processMessage(field.topic, "garbage".getBytes()); verify(fieldChangedObserverMock, times(0)).attributeChanged(any(), any(), any(), any(), anyBoolean()); assertThat(attributes.state.toString(), is("unknown")); diff --git a/bundles/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/internal/discovery/ObjectPropertyRequest.java b/bundles/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/internal/discovery/ObjectPropertyRequest.java index 89c6f1d190c..fe5aec83416 100644 --- a/bundles/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/internal/discovery/ObjectPropertyRequest.java +++ b/bundles/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/internal/discovery/ObjectPropertyRequest.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.omnilink.internal.exceptions.BridgeOfflineException; import org.openhab.binding.omnilink.internal.handler.OmnilinkBridgeHandler; @@ -42,14 +43,14 @@ public class ObjectPropertyRequest implements Iterab } private final OmnilinkBridgeHandler bridgeHandler; - private final ObjectPropertyRequests request; + private final ObjectPropertyRequests<@NonNull T> request; private final int objectNumber; private final int filter1; private final int filter2; private final int filter3; private final int offset; - private ObjectPropertyRequest(OmnilinkBridgeHandler bridgeHandler, ObjectPropertyRequests request, + private ObjectPropertyRequest(OmnilinkBridgeHandler bridgeHandler, ObjectPropertyRequests<@NonNull T> request, int objectNumber, int filter1, int filter2, int filter3, int offset) { this.bridgeHandler = bridgeHandler; this.request = request; diff --git a/bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/AbstractRioHandlerCallback.java b/bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/AbstractRioHandlerCallback.java index b0a9fa72181..41b95d548e7 100644 --- a/bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/AbstractRioHandlerCallback.java +++ b/bundles/org.openhab.binding.russound/src/main/java/org/openhab/binding/russound/internal/rio/AbstractRioHandlerCallback.java @@ -40,7 +40,7 @@ public abstract class AbstractRioHandlerCallback implements RioHandlerCallback { @Override public void removeListener(String channelId, RioHandlerCallbackListener listener) { for (ListenerState listenerState : listeners) { - if (listenerState.channelId.equals(channelId) && listenerState.listener == listener) { + if (listenerState.channelId.equals(channelId) && listener.equals(listenerState.listener)) { listeners.remove(listenerState); } } diff --git a/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/protocol/RemoteControllerLegacy.java b/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/protocol/RemoteControllerLegacy.java index 3d18cc7dbbc..1af64dd31c6 100644 --- a/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/protocol/RemoteControllerLegacy.java +++ b/bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/protocol/RemoteControllerLegacy.java @@ -285,7 +285,7 @@ public class RemoteControllerLegacy extends RemoteController { @Override public boolean isConnected() { - return socket != null && !socket.isClosed() && socket != null && socket.isConnected(); + return socket != null && !socket.isClosed() && socket.isConnected(); } private String createRegistrationPayload(String ip) throws IOException { diff --git a/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyDynamicStateDescriptionProvider.java b/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyDynamicStateDescriptionProvider.java index d9355d040b9..370dea7781a 100644 --- a/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyDynamicStateDescriptionProvider.java +++ b/bundles/org.openhab.binding.spotify/src/main/java/org/openhab/binding/spotify/internal/handler/SpotifyDynamicStateDescriptionProvider.java @@ -15,6 +15,7 @@ package org.openhab.binding.spotify.internal.handler; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -41,9 +42,9 @@ public class SpotifyDynamicStateDescriptionProvider extends BaseDynamicStateDesc public void setDevices(ChannelUID channelUID, List spotifyDevices) { final List devices = devicesByChannel.get(channelUID); - if (devices == null || (spotifyDevices.size() != devices.size() - || !spotifyDevices.stream().allMatch(sd -> devices.stream().anyMatch( - d -> sd.getId() == d.getId() && d.getName() != null && d.getName().equals(sd.getName()))))) { + if (devices == null || (spotifyDevices.size() != devices.size() || !spotifyDevices.stream() + .allMatch(sd -> devices.stream().anyMatch(d -> Objects.equals(sd.getId(), d.getId()) + && d.getName() != null && d.getName().equals(sd.getName()))))) { devicesByChannel.put(channelUID, spotifyDevices); setStateOptions(channelUID, spotifyDevices.stream() .map(device -> new StateOption(device.getId(), device.getName())).collect(Collectors.toList())); diff --git a/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureThingHandler.java b/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureThingHandler.java index 2fd70a94447..3163c84ca1f 100644 --- a/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureThingHandler.java +++ b/bundles/org.openhab.binding.verisure/src/main/java/org/openhab/binding/verisure/internal/handler/VerisureThingHandler.java @@ -20,6 +20,7 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.concurrent.TimeUnit; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.verisure.internal.DeviceStatusListener; @@ -51,7 +52,7 @@ import com.google.gson.Gson; * */ @NonNullByDefault -public abstract class VerisureThingHandler extends BaseThingHandler +public abstract class VerisureThingHandler<@NonNull T extends VerisureThingDTO> extends BaseThingHandler implements DeviceStatusListener { protected final Logger logger = LoggerFactory.getLogger(VerisureThingHandler.class); diff --git a/pom.xml b/pom.xml index 55c0ef82c96..f9f62e97e87 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 3.9.0 2.9.1 1.9.23 - 0.15.0 + 0.16.0 2.0.7 2.38.0