From 06c1157e26e34e81fc49506ce78708ffbab2f5ea Mon Sep 17 00:00:00 2001 From: mlobstein Date: Wed, 26 Aug 2020 09:15:43 -0500 Subject: [PATCH] [oppo] rollforward a few review changes from sister bindings and fix a title (#8335) * Rollforward a few review changes * fix thread naming convention Signed-off-by: Michael Lobstein --- .../org.openhab.binding.oppo/src/main/feature/feature.xml | 2 +- .../binding/oppo/internal/communication/OppoCommand.java | 2 +- .../binding/oppo/internal/communication/OppoConnector.java | 4 ++-- .../binding/oppo/internal/communication/OppoIpConnector.java | 4 ++-- .../oppo/internal/communication/OppoMessageEvent.java | 4 ++-- .../oppo/internal/communication/OppoReaderThread.java | 5 +++-- .../oppo/internal/communication/OppoSerialConnector.java | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bundles/org.openhab.binding.oppo/src/main/feature/feature.xml b/bundles/org.openhab.binding.oppo/src/main/feature/feature.xml index 9ebc366e375e2..3e9efe058768a 100644 --- a/bundles/org.openhab.binding.oppo/src/main/feature/feature.xml +++ b/bundles/org.openhab.binding.oppo/src/main/feature/feature.xml @@ -2,7 +2,7 @@ mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features - + openhab-runtime-base openhab-transport-serial mvn:org.openhab.addons.bundles/org.openhab.binding.oppo/${project.version} diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java index eb1ceeeb28e65..002ca93b00810 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoCommand.java @@ -66,7 +66,7 @@ public enum OppoCommand { SET_INPUT_SOURCE("SIS"), NO_OP("NOP"); - private String value; + private final String value; public static final Set INITIAL_COMMANDS = new HashSet<>( Arrays.asList(QUERY_POWER_STATUS, QUERY_FIRMWARE_VERSION, QUERY_VOLUME, QUERY_HDMI_RESOLUTION, diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoConnector.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoConnector.java index d6ab876362a0b..aa0bf18b496d4 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoConnector.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoConnector.java @@ -58,7 +58,7 @@ public abstract class OppoConnector { private @Nullable Thread readerThread; - private List listeners = new ArrayList<>(); + private final List listeners = new ArrayList<>(); /** * Called when using direct IP connection for 83/93/95/103/105 @@ -135,12 +135,12 @@ protected void cleanup() { } if (readerThread != null) { readerThread.interrupt(); + this.readerThread = null; try { readerThread.join(3000); } catch (InterruptedException e) { logger.warn("Error joining readerThread: {}", e.getMessage()); } - this.readerThread = null; } } diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoIpConnector.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoIpConnector.java index aaf149b48e244..3ecd13c724925 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoIpConnector.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoIpConnector.java @@ -35,8 +35,8 @@ public class OppoIpConnector extends OppoConnector { private final Logger logger = LoggerFactory.getLogger(OppoIpConnector.class); - private @Nullable String address; - private int port; + private final @Nullable String address; + private final int port; private @Nullable Socket clientSocket; diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoMessageEvent.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoMessageEvent.java index 5a32eab728165..d329a877f1c44 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoMessageEvent.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoMessageEvent.java @@ -25,8 +25,8 @@ public class OppoMessageEvent extends EventObject { private static final long serialVersionUID = 1L; - private String key; - private String value; + private final String key; + private final String value; public OppoMessageEvent(Object source, String key, String value) { super(source); diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoReaderThread.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoReaderThread.java index a4b9223464182..9d99e4596e1b8 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoReaderThread.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoReaderThread.java @@ -40,9 +40,10 @@ public class OppoReaderThread extends Thread { * Constructor * * @param connector the object that should handle the received message + * @param connectionId a string that uniquely identifies the particular connection */ - public OppoReaderThread(OppoConnector connector, String uid) { - super(OppoBindingConstants.BINDING_ID + "-" + uid); + public OppoReaderThread(OppoConnector connector, String connectionId) { + super("OH-binding-" + OppoBindingConstants.THING_TYPE_PLAYER + "-" + connectionId); this.connector = connector; setDaemon(true); } diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoSerialConnector.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoSerialConnector.java index a031d4d2542a5..ff288e0dcf7a9 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoSerialConnector.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/communication/OppoSerialConnector.java @@ -37,8 +37,8 @@ public class OppoSerialConnector extends OppoConnector { private final Logger logger = LoggerFactory.getLogger(OppoSerialConnector.class); - private String serialPortName; - private SerialPortManager serialPortManager; + private final String serialPortName; + private final SerialPortManager serialPortManager; private @Nullable SerialPort serialPort;