From b3d5accca26bdb60e445c731d9107b5e10dffd86 Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 16 Apr 2020 13:22:23 +0000 Subject: [PATCH] I2CP: Fix client notifier thread name --- .../net/i2p/client/impl/I2PSessionImpl.java | 24 +++++++++++++++---- .../src/net/i2p/client/impl/SubSession.java | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java index 563292a7f..7fa66c8ce 100644 --- a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java @@ -814,7 +814,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 + (connected - startConnect) + "ms - ready to participate in the network!"); } - Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true); + Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getName(), true); notifier.start(); startIdleMonitor(); startVerifyUsage(); @@ -1475,6 +1475,25 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 protected String getPrefix() { StringBuilder buf = new StringBuilder(); buf.append('['); + getName(buf); + buf.append('(').append(_state.toString()).append(')'); + buf.append("]: "); + return buf.toString(); + } + + /** + * @since 0.9.46 + */ + protected String getName() { + StringBuilder buf = new StringBuilder(); + getName(buf); + return buf.toString(); + } + + /** + * @since 0.9.46 + */ + private void getName(StringBuilder buf) { String s = _options.getProperty("inbound.nickname"); if (s != null) buf.append(s); @@ -1483,9 +1502,6 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 SessionId id = _sessionId; if (id != null) buf.append(" #").append(id.getSessionId()); - buf.append('(').append(_state.toString()).append(')'); - buf.append("]: "); - return buf.toString(); } /** diff --git a/core/java/src/net/i2p/client/impl/SubSession.java b/core/java/src/net/i2p/client/impl/SubSession.java index 451a351d2..5a7dfc069 100644 --- a/core/java/src/net/i2p/client/impl/SubSession.java +++ b/core/java/src/net/i2p/client/impl/SubSession.java @@ -129,7 +129,7 @@ class SubSession extends I2PSessionMuxedImpl { } synchronized(_stateLock) { if (_state != State.OPEN) { - Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true); + Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getName(), true); notifier.start(); changeState(State.OPEN); }