Skip to content

Commit 0cf0234

Browse files
authored
[To dev/1.3] Pipe: Restore RPC thread name after Pipe receiver exit (#16344) (#16345)
* thread name * thread name
1 parent 0dcd3e6 commit 0cf0234

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/receiver/IoTDBFileReceiver.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public abstract class IoTDBFileReceiver implements IoTDBReceiver {
7272
private static final AtomicLong RECEIVER_ID_GENERATOR = new AtomicLong(0);
7373
protected final AtomicLong receiverId = new AtomicLong(0);
7474

75+
// Used to restore the original thread name when the receiver is closed.
76+
private String originalThreadName;
77+
7578
protected String username = CONNECTOR_IOTDB_USER_DEFAULT_VALUE;
7679
protected String password = CONNECTOR_IOTDB_PASSWORD_DEFAULT_VALUE;
7780

@@ -113,6 +116,9 @@ protected TPipeTransferResp handleTransferHandshakeV1(final PipeTransferHandshak
113116
return new TPipeTransferResp(status);
114117
}
115118

119+
if (originalThreadName == null) {
120+
originalThreadName = Thread.currentThread().getName();
121+
}
116122
receiverId.set(RECEIVER_ID_GENERATOR.incrementAndGet());
117123
Thread.currentThread()
118124
.setName(
@@ -897,6 +903,10 @@ public synchronized void handleExit() {
897903
closeSession();
898904

899905
LOGGER.info("Receiver id = {}: Handling exit: Receiver exited.", receiverId.get());
906+
907+
if (originalThreadName != null) {
908+
Thread.currentThread().setName(originalThreadName);
909+
}
900910
}
901911

902912
protected abstract void closeSession();

0 commit comments

Comments
 (0)