Normalize thread names (#17804)

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
lsiepel 2024-12-08 01:15:43 +01:00 committed by Ciprian Pascu
parent 8803ad0c0a
commit 8176c827aa
30 changed files with 73 additions and 53 deletions

View File

@ -579,7 +579,8 @@ public class GoogleTVConnectionManager {
logger.trace("{} - Starting Reader Thread for {}:{}", handler.getThingID(), config.ipAddress,
config.googletvPort);
Thread readerThread = new Thread(this::readerThreadJob, "GoogleTV reader " + handler.getThingID());
Thread readerThread = new Thread(this::readerThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVReader");
readerThread.setDaemon(true);
readerThread.start();
this.readerThread = readerThread;
@ -587,7 +588,8 @@ public class GoogleTVConnectionManager {
logger.trace("{} - Starting Sender Thread for {}:{}", handler.getThingID(), config.ipAddress,
config.googletvPort);
Thread senderThread = new Thread(this::senderThreadJob, "GoogleTV sender " + handler.getThingID());
Thread senderThread = new Thread(this::senderThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVSender");
senderThread.setDaemon(true);
senderThread.start();
this.senderThread = senderThread;
@ -698,12 +700,14 @@ public class GoogleTVConnectionManager {
this.shimServerSocket = serverSocket;
this.shimQueue.clear();
Thread readerThread = new Thread(this::shimReaderThreadJob, "GoogleTV shim reader");
Thread readerThread = new Thread(this::shimReaderThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVShimReader");
readerThread.setDaemon(true);
readerThread.start();
this.shimReaderThread = readerThread;
Thread senderThread = new Thread(this::shimSenderThreadJob, "GoogleTV shim sender");
Thread senderThread = new Thread(this::shimSenderThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVShimSender");
senderThread.setDaemon(true);
senderThread.start();
this.shimSenderThread = senderThread;

View File

@ -443,12 +443,14 @@ public class ShieldTVConnectionManager {
setStatus(false, "offline.initializing");
Thread readerThread = new Thread(this::readerThreadJob, "ShieldTV reader " + handler.getThingID());
Thread readerThread = new Thread(this::readerThreadJob,
"OH-binding-" + handler.getThingUID() + "-ShieldTVReader");
readerThread.setDaemon(true);
readerThread.start();
this.readerThread = readerThread;
Thread senderThread = new Thread(this::senderThreadJob, "ShieldTV sender " + handler.getThingID());
Thread senderThread = new Thread(this::senderThreadJob,
"OH-binding-" + handler.getThingUID() + "-ShieldTVSender");
senderThread.setDaemon(true);
senderThread.start();
this.senderThread = senderThread;
@ -513,13 +515,13 @@ public class ShieldTVConnectionManager {
this.shimServerSocket = serverSocket;
Thread readerThread = new Thread(this::shimReaderThreadJob,
"ShieldTV shim reader " + handler.getThingID());
"OH-binding-" + handler.getThingUID() + "-ShieldTVShimReader");
readerThread.setDaemon(true);
readerThread.start();
this.shimReaderThread = readerThread;
Thread senderThread = new Thread(this::shimSenderThreadJob,
"ShieldTV shim sender" + handler.getThingID());
"OH-binding-" + handler.getThingUID() + "-ShieldTVShimSender");
senderThread.setDaemon(true);
senderThread.start();
this.shimSenderThread = senderThread;

View File

@ -242,12 +242,12 @@ public class AnthemHandler extends BaseThingHandler {
scheduleConnectRetry(reconnectIntervalMinutes);
return;
}
Thread localReaderThread = new Thread(this::readerThreadJob, "Anthem reader");
Thread localReaderThread = new Thread(this::readerThreadJob, "OH-binding-" + getThing().getUID() + "-Reader");
localReaderThread.setDaemon(true);
localReaderThread.start();
this.readerThread = localReaderThread;
Thread localSenderThread = new Thread(this::senderThreadJob, "Anthem sender");
Thread localSenderThread = new Thread(this::senderThreadJob, "OH-binding-" + getThing().getUID() + "-Sender");
localSenderThread.setDaemon(true);
localSenderThread.start();
this.senderThread = localSenderThread;

View File

@ -290,7 +290,7 @@ public class RemoteArgoApiServerStub {
// to stop, actually)
s.setStopTimeout(1000L);
try {
new Thread() {
new Thread("OH-binding-" + this.id + "-APIStub") {
@Override
public void run() {
try {

View File

@ -52,7 +52,8 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
private final ArrayBlockingQueue<Message> requests = new ArrayBlockingQueue<>(1024);
private final Map<InstanceKey, EchonetObject> devicesByKey = new HashMap<>();
private final EchonetMessageBuilder messageBuilder = new EchonetMessageBuilder();
private final Thread networkingThread = new Thread(this::poll);
private final Thread networkingThread = new Thread(this::poll,
"OH-binding-" + EchonetLiteBindingConstants.BINDING_ID);
private final EchonetMessage echonetMessage = new EchonetMessage();
private final MonotonicClock clock = new MonotonicClock();
@ -76,8 +77,6 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
logger.debug("Binding echonet channel");
echonetChannel = new EchonetChannel(discoveryKey.address);
logger.debug("Starting networking thread");
networkingThread.setName("OH-binding-" + EchonetLiteBindingConstants.BINDING_ID);
networkingThread.setDaemon(true);
networkingThread.start();
}

View File

@ -82,10 +82,10 @@ public class EkeyHandler extends BaseThingHandler implements EkeyPacketListener
scheduler.submit(() -> {
populateChannels(config.protocol);
String readerThreadName = "OH-binding-" + getThing().getUID().getAsString();
EkeyUdpPacketReceiver localReceiver = receiver = new EkeyUdpPacketReceiver(
Objects.requireNonNullElse(config.natIp, config.ipAddress), config.port, readerThreadName);
Objects.requireNonNullElse(config.natIp, config.ipAddress), config.port,
"OH-binding-" + getThing().getUID());
localReceiver.addEkeyPacketListener(this);
try {
localReceiver.openConnection();

View File

@ -397,7 +397,8 @@ public class Clip2Bridge implements Closeable {
public void onGoAway(@Nullable Session session, @Nullable GoAwayFrame frame) {
Objects.requireNonNull(session);
if (session.equals(http2Session)) {
Thread recreateThread = new Thread(() -> recreateSession());
Thread recreateThread = new Thread(() -> recreateSession(),
"OH-binding-" + bridgeHandler.getThing().getUID() + "-RecreateSession");
Clip2Bridge.this.recreateThread = recreateThread;
recreateThread.start();
}

View File

@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.insteon.internal.InsteonBindingConstants;
import org.openhab.binding.insteon.internal.InsteonLegacyBindingConstants;
import org.openhab.binding.insteon.internal.config.InsteonLegacyNetworkConfiguration;
import org.openhab.binding.insteon.internal.device.InsteonAddress;
@ -178,9 +179,9 @@ public class LegacyPort {
}
readThread = new Thread(reader);
setParamsAndStart(readThread, "Reader");
setParamsAndStart(readThread, "OH-binding-" + InsteonBindingConstants.BINDING_ID + "-LegacyReader");
writeThread = new Thread(writer);
setParamsAndStart(writeThread, "Writer");
setParamsAndStart(writeThread, "OH-binding-" + InsteonBindingConstants.BINDING_ID + "-LegacyWriter");
if (!mdbb.isComplete()) {
modem.initialize();

View File

@ -93,11 +93,8 @@ public class IntesisBoxHandler extends BaseThingHandler implements IntesisBoxCha
if (!config.ipAddress.isEmpty()) {
updateStatus(ThingStatus.UNKNOWN);
scheduler.submit(() -> {
String readerThreadName = "OH-binding-" + getThing().getUID().getAsString();
IntesisBoxSocketApi intesisLocalApi = intesisBoxSocketApi = new IntesisBoxSocketApi(config.ipAddress,
config.port, readerThreadName);
config.port, "OH-binding-" + getThing().getUID());
intesisLocalApi.addIntesisBoxChangeListener(this);
try {
intesisLocalApi.openConnection();

View File

@ -32,6 +32,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import org.openhab.binding.keba.internal.KebaBindingConstants;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.slf4j.Logger;
@ -71,7 +72,8 @@ public class KeContactTransceiver {
selector = Selector.open();
if (transceiverThread == null) {
transceiverThread = new Thread(transceiverRunnable, "OH-binding-Keba-Transceiver");
transceiverThread = new Thread(transceiverRunnable,
"OH-binding-" + KebaBindingConstants.BINDING_ID + "-Transceiver");
transceiverThread.start();
}

View File

@ -86,7 +86,7 @@ public abstract class LxWsSecurity {
authenticationLock.unlock();
}
};
new Thread(init).start();
new Thread(init, "OH-binding-" + thingHandler.getThingId() + "-Authenticate").start();
}
/**

View File

@ -216,7 +216,7 @@ public class IPBridgeHandler extends LutronBridgeHandler {
sendCommand(new LIPCommand(TargetType.BRIDGE, LutronOperation.QUERY, LutronCommandType.SYSTEM, null,
SYSTEM_DBEXPORTDATETIME));
messageSender = new Thread(this::sendCommandsThread, "Lutron sender");
messageSender = new Thread(this::sendCommandsThread, "OH-binding-" + getThing().getUID() + "-IPBridgeSender");
messageSender.start();
logger.debug("Starting keepAlive job with interval {}", heartbeatInterval);

View File

@ -304,12 +304,12 @@ public class LeapBridgeHandler extends LutronBridgeHandler implements LeapMessag
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, STATUS_INITIALIZING);
Thread readerThread = new Thread(this::readerThreadJob, "Lutron reader");
Thread readerThread = new Thread(this::readerThreadJob, "OH-binding-" + getThing().getUID() + "-BridgeReader");
readerThread.setDaemon(true);
readerThread.start();
this.readerThread = readerThread;
Thread senderThread = new Thread(this::senderThreadJob, "Lutron sender");
Thread senderThread = new Thread(this::senderThreadJob, "OH-binding-" + getThing().getUID() + "-BridgeSender");
senderThread.setDaemon(true);
senderThread.start();
this.senderThread = senderThread;

View File

@ -139,7 +139,7 @@ public class LuxomBridgeHandler extends BaseBridgeHandler {
updateStatus(ThingStatus.ONLINE);
messageSender = new Thread(this::sendCommandsThread, "Luxom sender");
messageSender = new Thread(this::sendCommandsThread, "OH-binding-" + getThing().getUID() + "-Sender");
messageSender.start();
logger.debug("Starting heartbeat job with interval {} (seconds)", HEARTBEAT_INTERVAL_SECONDS);

View File

@ -340,7 +340,8 @@ public class MaxCubeBridgeHandler extends BaseBridgeHandler {
pollingJob = scheduler.scheduleWithFixedDelay(this::refreshData, 0, refreshInterval, TimeUnit.SECONDS);
}
if (queueConsumerThread == null || !queueConsumerThread.isAlive()) {
queueConsumerThread = new Thread(new QueueConsumer(commandQueue), "max-queue-consumer");
queueConsumerThread = new Thread(new QueueConsumer(commandQueue),
"OH-binding-" + getThing().getUID() + "-max-queue-consumer");
queueConsumerThread.setDaemon(true);
queueConsumerThread.start();
}

View File

@ -12,6 +12,8 @@
*/
package org.openhab.binding.mihome.internal.socket;
import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.BINDING_ID;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
@ -71,7 +73,7 @@ public abstract class XiaomiSocket {
*/
public XiaomiSocket(int port, String owner) {
this.port = port;
socketReceiveThread.setName("XiaomiSocketReceiveThread(" + port + ", " + owner + ")");
socketReceiveThread.setName("OH-binding-" + BINDING_ID + "-XiaomiSocket(" + port + ", " + owner + ")");
}
public void initialize() {

View File

@ -32,6 +32,7 @@ import java.util.concurrent.CompletableFuture;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.milight.internal.MilightBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -185,7 +186,7 @@ public class MilightV6SessionManager implements Runnable, Closeable {
throw new IllegalArgumentException("keepAliveInterval not within given limits!");
}
sessionThread = new Thread(this, "SessionThread");
sessionThread = new Thread(this, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-SessionThread");
}
/**

View File

@ -21,6 +21,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.milight.internal.MilightBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -48,7 +49,7 @@ public class QueuedSend implements Runnable, Closeable {
*/
public void start() {
willbeclosed = false;
thread = new Thread(this);
thread = new Thread(this, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-QueuedSend");
thread.start();
}

View File

@ -92,8 +92,8 @@ public class EmulatedV6Bridge {
FAKE_MAC[2], FAKE_MAC[3], FAKE_MAC[4], FAKE_MAC[5], 1 };
EmulatedV6Bridge() {
new Thread(this::runDiscovery).start();
new Thread(this::runBrigde).start();
new Thread(this::runDiscovery, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-runDiscovery").start();
new Thread(this::runBridge, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-runBridge").start();
}
private void replaceWithMac(byte[] data, int offset) {
@ -144,7 +144,7 @@ public class EmulatedV6Bridge {
}
}
public void runBrigde() {
public void runBridge() {
try {
byte[] a = new byte[0];
DatagramPacket sPacket = new DatagramPacket(a, a.length);

View File

@ -203,7 +203,7 @@ public abstract class PentairBaseBridgeHandler extends BaseBridgeHandler
return;
}
Thread parserThread = new Thread(parser, "OH-pentair-" + this.getThing().getUID() + "-parser");
Thread parserThread = new Thread(parser, "OH-binding-" + this.getThing().getUID() + "-parser");
this.parserThread = parserThread;
parserThread.setDaemon(true);

View File

@ -24,6 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.openhab.binding.russound.internal.RussoundBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -127,8 +128,10 @@ public class SocketChannelSession implements SocketSession {
responses.clear();
dispatchingThread = new Thread(new Dispatcher());
responseThread = new Thread(new ResponseReader());
dispatchingThread = new Thread(new Dispatcher(),
"OH-binding-" + RussoundBindingConstants.BINDING_ID + "-dispatcher");
responseThread = new Thread(new ResponseReader(),
"OH-binding-" + RussoundBindingConstants.BINDING_ID + "-responseReader");
dispatchingThread.start();
responseThread.start();

View File

@ -23,6 +23,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.satel.internal.SatelBindingConstants;
import org.openhab.binding.satel.internal.command.IntegraVersionCommand;
import org.openhab.binding.satel.internal.command.SatelCommand;
import org.openhab.binding.satel.internal.command.SatelCommand.State;
@ -520,7 +521,7 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL
SatelModule.this.communicationLoop(CommunicationWatchdog.this);
logger.debug("Communication thread stopped");
}
});
}, "OH-binding-" + SatelBindingConstants.BINDING_ID + "-dispatcher");
thread.start();
this.thread = thread;
// if module is not initialized yet, send version command

View File

@ -24,6 +24,7 @@ import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpStatus;
import org.openhab.binding.shelly.internal.ShellyBindingConstants;
import org.openhab.binding.shelly.internal.ShellyHandlerFactory;
import org.openhab.binding.shelly.internal.api.ShellyApiException;
import org.openhab.binding.shelly.internal.api.ShellyApiInterface;
@ -103,7 +104,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
// maybe the device restarts before returning the http response
}
setRestarted(th, uid); // refresh after reboot
}).start();
}, "OH-binding-" + ShellyBindingConstants.BINDING_ID + "-" + uid + "-deviceReboot").start();
refreshTimer = profile.isMotion ? 60 : 30;
} else {
message = getMessageS("action.restart.confirm", MCINFO);
@ -162,7 +163,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
// maybe the device restarts before returning the http response
}
setRestarted(th, uid); // refresh after reboot
}).start();
}, "OH-binding-" + ShellyBindingConstants.BINDING_ID + "-" + uid + "-reboot").start();
// The device needs a restart after changing the peer mode
message = getMessageP("action.restart.info", MCINFO);
@ -188,7 +189,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
} catch (ShellyApiException e) {
// maybe the device restarts before returning the http response
}
}).start();
}, "OH-binding-" + ShellyBindingConstants.BINDING_ID + "-" + uid + "-factoryReset").start();
message = getMessageP("action.reset.confirm", MCINFO, serviceName);
refreshTimer = 5;
}
@ -216,7 +217,7 @@ public class ShellyManagerActionPage extends ShellyManagerPage {
} catch (ShellyApiException e) {
// maybe the device restarts before returning the http response
}
}).start();
}, "OH-binding-" + ShellyBindingConstants.BINDING_ID + "-" + uid + "-setDebug").start();
message = getMessage("action.debug-confirm", enable ? "enabled" : "disabled");
refreshTimer = 3;

View File

@ -31,6 +31,7 @@ import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.openhab.binding.shelly.internal.ShellyBindingConstants;
import org.openhab.binding.shelly.internal.ShellyHandlerFactory;
import org.openhab.binding.shelly.internal.api.ShellyApiException;
import org.openhab.binding.shelly.internal.api.ShellyApiInterface;
@ -134,7 +135,7 @@ public class ShellyManagerOtaPage extends ShellyManagerPage {
// maybe the device restarts before returning the http response
logger.warn("{}: {}", th.getThingName(), getMessage("fwupdate.initiated", e.toString()));
}
}).start();
}, "OH-binding-" + ShellyBindingConstants.BINDING_ID + "-" + uid + "-scheduleUpdate").start();
} else {
String message = getMessageP("fwupdate.confirm", MCINFO);
properties.put(ATTRIBUTE_MESSAGE, message);

View File

@ -145,7 +145,8 @@ public class SilvercrestWifiSocketMediatorImpl implements SilvercrestWifiSocketM
try {
this.receiver = new SilvercrestWifiSocketUpdateReceiverRunnable(this,
SilvercrestWifiSocketBindingConstants.WIFI_SOCKET_DEFAULT_UDP_PORT);
this.receiverThread = new Thread(this.receiver);
this.receiverThread = new Thread(this.receiver,
"OH-binding-" + SilvercrestWifiSocketBindingConstants.BINDING_ID + "-receiver");
this.receiverThread.start();
logger.debug("Invoked the start of receiver thread.");
} catch (SocketException e) {

View File

@ -129,7 +129,8 @@ public class TelldusCoreBridgeHandler extends BaseBridgeHandler
}
private void setupDeviceController(TellstickBridgeConfiguration configuration) {
deviceController = new TelldusCoreDeviceController(configuration.resendInterval);
deviceController = new TelldusCoreDeviceController(configuration.resendInterval,
"OH-binding-" + getThing().getUID() + "-worker");
eventHandler.addListener((TelldusCoreDeviceController) deviceController);
}

View File

@ -55,11 +55,11 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
private Thread workerThread;
private SortedMap<Device, TelldusCoreSendEvent> messageQue;
public TelldusCoreDeviceController(long resendInterval) {
public TelldusCoreDeviceController(long resendInterval, final String threadName) {
this.resendInterval = resendInterval;
messageQue = Collections.synchronizedSortedMap(new TreeMap<>());
telldusCoreWorker = new TelldusCoreWorker(messageQue);
workerThread = new Thread(telldusCoreWorker);
workerThread = new Thread(telldusCoreWorker, threadName);
}
@Override

View File

@ -276,8 +276,7 @@ public class VitotronicBridgeHandler extends BaseBridgeHandler {
if (!isConnect) {
openSocket();
Thread thread = new Thread(socketReceiverRunnable);
thread.setName("VitotronicSocketThread");
Thread thread = new Thread(socketReceiverRunnable, "OH-binding-" + getThing().getUID() + "-SocketThread");
thread.start();
}
}

View File

@ -17,6 +17,7 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;
import org.openhab.binding.yeelight.internal.YeelightBindingConstants;
import org.openhab.binding.yeelight.internal.lib.device.ConnectState;
import org.openhab.binding.yeelight.internal.lib.device.DeviceBase;
import org.openhab.binding.yeelight.internal.lib.device.DeviceMethod;
@ -120,7 +121,7 @@ public class WifiConnection implements ConnectionBase {
mDevice.setConnectionState(ConnectState.DISCONNECTED);
mSocket = null;
}
});
}, "OH-binding-" + YeelightBindingConstants.BINDING_ID + "-WifiConnection");
mConnectThread.start();
return false;
}

View File

@ -29,6 +29,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import org.openhab.binding.yeelight.internal.YeelightBindingConstants;
import org.openhab.binding.yeelight.internal.lib.device.DeviceBase;
import org.openhab.binding.yeelight.internal.lib.device.DeviceFactory;
import org.openhab.binding.yeelight.internal.lib.device.DeviceStatus;
@ -98,7 +99,7 @@ public class DeviceManager {
} finally {
stopDiscovery();
}
}).start();
}, "OH-binding-" + YeelightBindingConstants.BINDING_ID + "-DeviceManager").start();
}
}