Skip to content

Commit 6fb776c

Browse files
authored
Pipe: Restore RPC thread name after Pipe receiver exit (apache#16344)
* thread name * thread name
1 parent d29e45c commit 6fb776c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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(
@@ -919,6 +925,10 @@ public synchronized void handleExit() {
919925
closeSession();
920926

921927
LOGGER.info("Receiver id = {}: Handling exit: Receiver exited.", receiverId.get());
928+
929+
if (originalThreadName != null) {
930+
Thread.currentThread().setName(originalThreadName);
931+
}
922932
}
923933

924934
protected abstract void closeSession();

0 commit comments

Comments
 (0)