Skip to content

Commit

Permalink
Normalize thread names (2) (#17849)
Browse files Browse the repository at this point in the history
* Normalize thread names

Signed-off-by: AndrewFG <[email protected]>
  • Loading branch information
andrewfg authored Dec 5, 2024
1 parent 35630e1 commit 388dc6b
Show file tree
Hide file tree
Showing 43 changed files with 93 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.concurrent.TimeoutException;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.broadlink.internal.BroadlinkBindingConstants;
import org.openhab.binding.broadlink.internal.BroadlinkProtocol;
import org.openhab.binding.broadlink.internal.NetworkUtils;
import org.openhab.binding.broadlink.internal.socket.BroadlinkSocket;
Expand All @@ -37,6 +38,7 @@ private static class AsyncDiscoveryThread extends Thread {

AsyncDiscoveryThread(BroadlinkSocketListener listener, long timeoutMillis,
DiscoveryFinishedListener finishedListener, Logger logger) {
super(String.format("OH-binding-%s-%s", BroadlinkBindingConstants.BINDING_ID, "Discovery"));
this.listener = listener;
this.timeoutMillis = timeoutMillis;
this.finishedListener = finishedListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.broadlink.internal.BroadlinkBindingConstants;
import org.openhab.binding.broadlink.internal.ModelMapper;
import org.slf4j.Logger;

Expand Down Expand Up @@ -99,6 +100,7 @@ private void receiveData(@Nullable MulticastSocket socket, DatagramPacket dgram)
}

private ReceiverThread(Logger logger) {
super(String.format("OH-binding-%s-%s", BroadlinkBindingConstants.BINDING_ID, "Receiver"));
this.logger = logger;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public class X10Interface extends Thread implements SerialPortEventListener {
*
*/
public X10Interface(String serialPort, Cm11aBridgeHandler bridgeHandler) throws NoSuchPortException {
super();
super("OH-binding-" + bridgeHandler.getThing().getUID());
logger.trace("**** Constructing X10Interface for serial port: {} *******", serialPort);
portId = CommPortIdentifier.getPortIdentifier(serialPort);
this.bridgeHandler = bridgeHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.denonmarantz.internal.DenonMarantzBindingConstants;
import org.openhab.binding.denonmarantz.internal.config.DenonMarantzConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class DenonMarantzTelnetClientThread extends Thread {
private @Nullable BufferedReader in;

public DenonMarantzTelnetClientThread(DenonMarantzConfiguration config, DenonMarantzTelnetListener listener) {
super(String.format("OH-binding-%s-%s", DenonMarantzBindingConstants.BINDING_ID, "TelnetClient"));
logger.debug("Denon listener created");
this.config = config;
this.listener = listener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@NonNullByDefault
public class DigiplexBindingConstants {

private static final String BINDING_ID = "digiplex";
public static final String BINDING_ID = "digiplex";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.digiplex.internal.DigiplexBindingConstants;
import org.openhab.binding.digiplex.internal.DigiplexBridgeConfiguration;
import org.openhab.binding.digiplex.internal.communication.CommunicationStatus;
import org.openhab.binding.digiplex.internal.communication.DigiplexMessageHandler;
Expand Down Expand Up @@ -303,7 +304,7 @@ private class DigiplexReceiverThread extends Thread {
private final InputStream stream;

DigiplexReceiverThread(InputStream stream) {
super("DigiplexReceiveThread");
super(String.format("OH-binding-%s-%s", DigiplexBindingConstants.BINDING_ID, "Receiver"));
this.stream = stream;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.doorbird.internal.DoorbirdBindingConstants;
import org.openhab.binding.doorbird.internal.api.DoorbirdSession;
import org.openhab.binding.doorbird.internal.handler.DoorbellHandler;
import org.slf4j.Logger;
Expand Down Expand Up @@ -58,6 +59,7 @@ public class DoorbirdUdpListener extends Thread {
private long lastDataTime;

public DoorbirdUdpListener(DoorbellHandler thingHandler) {
super(String.format("OH-binding-%s-%s", DoorbirdBindingConstants.BINDING_ID, "UdpListener"));
this.thingHandler = thingHandler;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ private synchronized void stopReceiverThreat() {
* The thread, which waits for data and submits the unique results addresses to the discovery results
*/
private class ReceiverThread extends Thread {

public ReceiverThread() {
super(String.format("OH-binding-%s-%s", FineOffsetWeatherStationBindingConstants.BINDING_ID, "Receiver"));
}

@Override
public void run() {
DatagramSocket socket = getSocket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.regex.Pattern;

import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants;
import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType;
import org.openhab.binding.globalcache.internal.command.CommandGetstate;
import org.openhab.binding.globalcache.internal.command.CommandGetversion;
Expand Down Expand Up @@ -452,7 +453,7 @@ private class CommandProcessor extends Thread {
private ConnectionManager connectionManager;

public CommandProcessor() {
super("GlobalCache Command Processor");
super(String.format("OH-binding-%s-%s", GlobalCacheBindingConstants.BINDING_ID, "CommandProcessor"));
sendQueue = new LinkedBlockingQueue<>(SEND_QUEUE_MAX_DEPTH);
logger.debug("Processor for thing {} created request queue, depth={}", thingID(), SEND_QUEUE_MAX_DEPTH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;
import java.util.zip.GZIPInputStream;

import org.openhab.binding.ihc.internal.IhcBindingConstants;
import org.openhab.binding.ihc.internal.ws.datatypes.WSControllerState;
import org.openhab.binding.ihc.internal.ws.datatypes.WSFile;
import org.openhab.binding.ihc.internal.ws.datatypes.WSLoginResult;
Expand Down Expand Up @@ -456,6 +457,10 @@ public boolean resourceUpdate(WSResourceValue value) throws IhcExecption {
private class IhcResourceValueNotificationListener extends Thread {
private volatile boolean interrupted = false;

public IhcResourceValueNotificationListener() {
super(String.format("OH-binding-%s-%s", IhcBindingConstants.BINDING_ID, "NotificationListener"));
}

public void setInterrupted(boolean interrupted) {
this.interrupted = interrupted;
this.interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private class IpCameraFfmpegThread extends Thread {
public int countOfMotions;

IpCameraFfmpegThread() {
super(String.format("OH-binding-%s-%s", IpCameraBindingConstants.BINDING_ID, "Ffmpeg"));
setDaemon(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
@NonNullByDefault
public class IpCameraBindingConstants {
private static final String BINDING_ID = "ipcamera";
public static final String BINDING_ID = "ipcamera";
public static final String AUTH_HANDLER = "authorizationHandler";
public static final String AMCREST_HANDLER = "amcrestHandler";
public static final String COMMON_HANDLER = "commonHandler";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.openhab.binding.lirc.internal.LIRCBindingConstants;
import org.openhab.binding.lirc.internal.LIRCResponseException;
import org.openhab.binding.lirc.internal.messages.LIRCButtonEvent;
import org.openhab.binding.lirc.internal.messages.LIRCResponse;
Expand All @@ -45,6 +46,7 @@ public class LIRCStreamReader extends Thread {
private LIRCConnector connector;

public LIRCStreamReader(LIRCConnector connector, InputStream in) {
super(String.format("OH-binding-%s-%s", LIRCBindingConstants.BINDING_ID, "StreamReader"));
this.connector = connector;
this.in = in;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ private class LxServerThread extends Thread {
private Instant lastKeepAlive;

LxServerThread(int id) {
super(String.format("OH-binding-%s-%s", LxBindingConstants.BINDING_ID, "Server"));
debugId = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.magentatv.internal.MagentaTVBindingConstants;
import org.openhab.binding.magentatv.internal.MagentaTVHandlerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class MagentaTVPoweroffListener extends Thread {

public MagentaTVPoweroffListener(MagentaTVHandlerFactory handlerFactory,
@Nullable NetworkInterface networkInterface) throws IOException {
setName("OH-Binding-magentatv-upnp-listener");
super(String.format("OH-binding-%s-%s", MagentaTVBindingConstants.BINDING_ID, "PoweroffListener"));
setDaemon(true);

this.handlerFactory = handlerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.openhab.binding.meteostick.internal.MeteostickBindingConstants;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPort;
Expand Down Expand Up @@ -222,6 +223,10 @@ private void sendToMeteostick(String string) {
private class ReceiveThread extends Thread implements SerialPortEventListener {
private final Logger logger = LoggerFactory.getLogger(ReceiveThread.class);

public ReceiveThread() {
super(String.format("OH-binding-%s-%s", MeteostickBindingConstants.BINDING_ID, "Receiver"));
}

@Override
public void serialEvent(SerialPortEvent arg0) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.miio.internal.Message;
import org.openhab.binding.miio.internal.MiIoBindingConstants;
import org.openhab.binding.miio.internal.MiIoDevices;
import org.openhab.binding.miio.internal.Utils;
import org.openhab.binding.miio.internal.cloud.CloudConnector;
Expand Down Expand Up @@ -352,6 +353,11 @@ private synchronized void stopReceiverThreat() {
*
*/
private class ReceiverThread extends Thread {

public ReceiverThread() {
super(String.format("OH-binding-%s-%s", MiIoBindingConstants.BINDING_ID, "Receiver"));
}

@Override
public void run() {
DatagramSocket socket = getSocket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private class MessageSenderThread extends Thread {
private final String deviceId;

public MessageSenderThread(String deviceId) {
super("OH-binding-miio-MessageSenderThread-" + deviceId);
super(String.format("OH-binding-%s-%s-%s", MiIoBindingConstants.BINDING_ID, "Sender", deviceId));
setDaemon(true);
this.deviceId = deviceId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@NonNullByDefault
public class MPDBindingConstants {

private static final String BINDING_ID = "mpd";
public static final String BINDING_ID = "mpd";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_MPD = new ThingTypeUID(BINDING_ID, "mpd");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mpd.internal.MPDBindingConstants;
import org.openhab.binding.mpd.internal.MPDException;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
Expand Down Expand Up @@ -58,6 +59,7 @@ public class MPDConnectionThread extends Thread {
private AtomicBoolean disposed = new AtomicBoolean(false);

public MPDConnectionThread(MPDResponseListener listener, String address, Integer port, String password) {
super(String.format("OH-binding-%s-%s", MPDBindingConstants.BINDING_ID, "Connection"));
this.listener = listener;
this.address = address;
this.port = port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
@NonNullByDefault
public class MyNiceBindingConstants {
private static final String BINDING_ID = "mynice";
public static final String BINDING_ID = "mynice";

// List of all Channel ids
public static final String CHANNEL_STATUS = "status";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.net.ssl.SSLSocket;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.mynice.internal.MyNiceBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,7 +40,7 @@ public class It4WifiConnector extends Thread {
private final OutputStreamWriter out;

public It4WifiConnector(It4WifiHandler handler, SSLSocket sslSocket) throws IOException {
super(It4WifiConnector.class.getName());
super(String.format("OH-binding-%s-%s", MyNiceBindingConstants.BINDING_ID, "WifiConnector"));
this.handler = handler;
this.in = new InputStreamReader(sslSocket.getInputStream());
this.out = new OutputStreamWriter(sslSocket.getOutputStream());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@NonNullByDefault
public class NetworkBindingConstants {

private static final String BINDING_ID = "network";
public static final String BINDING_ID = "network";

// List of all Thing Type UIDs
public static final ThingTypeUID BACKWARDS_COMPATIBLE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.network.internal.NetworkBindingConstants;
import org.openhab.binding.network.internal.dhcp.DHCPPacket.BadPacketException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -45,6 +46,7 @@ public class DHCPPacketListenerServer extends Thread {
private int currentPort = PRIVILEGED_PORT;

DHCPPacketListenerServer(IPRequestReceivedCallback listener) throws SocketException {
super(String.format("OH-binding-%s-%s", NetworkBindingConstants.BINDING_ID, "DHCPPacketListener"));
this.listener = listener;
try {
bindSocketTo(currentPort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public class NibeHeatPumpBindingConstants {

private static final String BINDING_ID = "nibeheatpump";
public static final String BINDING_ID = "nibeheatpump";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_F1X45_UDP = new ThingTypeUID(BINDING_ID, "f1x45-udp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.TooManyListenersException;

import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpBindingConstants;
import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
import org.openhab.binding.nibeheatpump.internal.config.NibeHeatPumpConfiguration;
import org.openhab.binding.nibeheatpump.internal.message.MessageFactory;
Expand Down Expand Up @@ -165,6 +166,7 @@ public class SerialReader extends Thread implements SerialPortEventListener {
final InputStream in;

SerialReader(InputStream in) {
super(String.format("OH-binding-%s-%s", NibeHeatPumpBindingConstants.BINDING_ID, "SerialReader"));
this.in = in;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Map;
import java.util.Random;

import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpBindingConstants;
import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
import org.openhab.binding.nibeheatpump.internal.config.NibeHeatPumpConfiguration;
import org.openhab.binding.nibeheatpump.internal.message.MessageFactory;
Expand Down Expand Up @@ -125,6 +126,10 @@ public void sendDatagram(NibeHeatPumpMessage msg) {
private class Reader extends Thread {
boolean interrupted = false;

public Reader() {
super(String.format("OH-binding-%s-%s", NibeHeatPumpBindingConstants.BINDING_ID, "SimulatorReader"));
}

@Override
public void interrupt() {
logger.debug("Data listener interupt request received");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.net.SocketException;
import java.util.Arrays;

import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpBindingConstants;
import org.openhab.binding.nibeheatpump.internal.NibeHeatPumpException;
import org.openhab.binding.nibeheatpump.internal.config.NibeHeatPumpConfiguration;
import org.openhab.binding.nibeheatpump.internal.message.ModbusReadRequestMessage;
Expand Down Expand Up @@ -124,6 +125,10 @@ public void sendDatagram(NibeHeatPumpMessage msg) throws NibeHeatPumpException {
private class Reader extends Thread {
boolean interrupted = false;

public Reader() {
super(String.format("OH-binding-%s-%s", NibeHeatPumpBindingConstants.BINDING_ID, "UDPReader"));
}

@Override
public void interrupt() {
interrupted = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public String getErrorMessage() {
private HubCommunicationThreadState currentState = HubCommunicationThreadState.STARTING;

public HubCommunicationThread(HubConnection hubConnection, NoboHubBridgeHandler hubHandler, Duration timeout) {
super("OH-binding-" + hubHandler.getThing().getUID());
this.hubConnection = hubConnection;
this.hubHandler = hubHandler;
this.timeout = timeout;
Expand Down
Loading

0 comments on commit 388dc6b

Please sign in to comment.