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

[oppo] fix thread naming convention per comments in #8335 #8347

Merged
merged 11 commits into from
Aug 26, 2020
Prev Previous commit
fix thread naming convention
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
mlobstein committed Aug 26, 2020
commit d7b5d2f81f81deb707d6a1cca69f7c0398d70e76
4 changes: 3 additions & 1 deletion bundles/org.openhab.binding.oppo/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ public class OppoIpConnector extends OppoConnector {

private final @Nullable String address;
private final int port;
private final String uid;

private @Nullable Socket clientSocket;

@@ -45,10 +46,12 @@ public class OppoIpConnector extends OppoConnector {
*
* @param address the IP address of the player or serial over ip adapter
* @param port the TCP port to be used
* @param uid the thing uid string
*/
public OppoIpConnector(@Nullable String address, int port) {
public OppoIpConnector(@Nullable String address, int port, String uid) {
this.address = address;
this.port = port;
this.uid = uid;
}

@Override
@@ -61,7 +64,7 @@ public synchronized void open() throws OppoException {
dataOut = new DataOutputStream(clientSocket.getOutputStream());
dataIn = new DataInputStream(clientSocket.getInputStream());

Thread thread = new OppoReaderThread(this, this.address + ":" + this.port);
Thread thread = new OppoReaderThread(this, this.uid, this.address + ":" + this.port);
setReaderThread(thread);
thread.start();

Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
import java.util.Arrays;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.oppo.internal.OppoBindingConstants;
import org.openhab.binding.oppo.internal.OppoException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,10 +39,11 @@ public class OppoReaderThread extends Thread {
* Constructor
*
* @param connector the object that should handle the received message
* @param uid the thing uid string
* @param connectionId a string that uniquely identifies the particular connection
*/
public OppoReaderThread(OppoConnector connector, String connectionId) {
super("OH-binding-" + OppoBindingConstants.THING_TYPE_PLAYER + "-" + connectionId);
public OppoReaderThread(OppoConnector connector, String uid, String connectionId) {
super("OH-binding-" + uid + "-" + connectionId);
this.connector = connector;
setDaemon(true);
}
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ public class OppoSerialConnector extends OppoConnector {

private final String serialPortName;
private final SerialPortManager serialPortManager;
private final String uid;

private @Nullable SerialPort serialPort;

@@ -47,10 +48,12 @@ public class OppoSerialConnector extends OppoConnector {
*
* @param serialPortManager the serial port manager
* @param serialPortName the serial port name to be used
* @param uid the thing uid string
*/
public OppoSerialConnector(SerialPortManager serialPortManager, String serialPortName) {
public OppoSerialConnector(SerialPortManager serialPortManager, String serialPortName, String uid) {
this.serialPortManager = serialPortManager;
this.serialPortName = serialPortName;
this.uid = uid;
}

@Override
@@ -83,7 +86,7 @@ public synchronized void open() throws OppoException {
}
}

Thread thread = new OppoReaderThread(this, this.serialPortName);
Thread thread = new OppoReaderThread(this, this.uid, this.serialPortName);
setReaderThread(thread);
thread.start();

Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ public OppoHandler(Thing thing, OppoStateDescriptionOptionProvider stateDescript
@Override
public void initialize() {
OppoThingConfiguration config = getConfigAs(OppoThingConfiguration.class);
final String uid = this.getThing().getUID().getAsString();

// Check configuration settings
String configError = null;
@@ -157,9 +158,9 @@ public void initialize() {
}

if (serialPort != null) {
connector = new OppoSerialConnector(serialPortManager, serialPort);
connector = new OppoSerialConnector(serialPortManager, serialPort, uid);
} else if (port != null) {
connector = new OppoIpConnector(host, port);
connector = new OppoIpConnector(host, port, uid);
connector.overrideCmdPreamble(override);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,