Skip to content

Commit f175ea1

Browse files
committed
docs: 将注释“服务接口配置”改为英文“Service interface configuration”
1 parent 9995cb3 commit f175ea1

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

trpc-proto/trpc-rpc-support/src/main/java/com/tencent/trpc/proto/support/DefResponseFutureManager.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* @see DefResponseFuture
3737
*/
38-
public class DefResponseFutureManager implements ShutdownListener {
38+
public class DefResponseFutureManager {
3939

4040
private static final Logger LOG = LoggerFactory.getLogger(DefResponseFutureManager.class);
4141

@@ -47,9 +47,14 @@ public class DefResponseFutureManager implements ShutdownListener {
4747
* Store
4848
*/
4949
private final ConcurrentMap<Long, DefResponseFuture> futureMap = new ConcurrentHashMap<>();
50+
51+
/**
52+
* Internal shutdown listener that handles the shutdown of this manager
53+
*/
54+
private final ShutdownListener shutdownListener = new InternalShutdownListener();
5055

51-
public DefResponseFutureManager() {
52-
ConfigManager.getInstance().registerShutdownListener(this);
56+
public DefResponseFutureManager() {
57+
ConfigManager.getInstance().registerShutdownListener(shutdownListener);
5358
}
5459

5560
/**
@@ -167,12 +172,23 @@ public static void reset() {
167172
}
168173

169174
/**
170-
* Shutdown listener implementation to handle container shutdown
175+
* Get the internal shutdown listener for testing purposes
176+
*
177+
* @return the internal shutdown listener
178+
*/
179+
public ShutdownListener getShutdownListener() {
180+
return shutdownListener;
181+
}
182+
183+
/**
184+
* Internal shutdown listener implementation
171185
*/
172-
@Override
173-
public void onShutdown() {
174-
LOG.info("DefResponseFutureManager received shutdown notification");
175-
stop();
186+
private class InternalShutdownListener implements ShutdownListener {
187+
@Override
188+
public void onShutdown() {
189+
LOG.info("DefResponseFutureManager received shutdown notification");
190+
DefResponseFutureManager.this.stop();
191+
}
176192
}
177193

178194
/**

trpc-proto/trpc-rpc-support/src/test/java/com/tencent/trpc/proto/support/DefResponseFutureTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.tencent.trpc.core.common.config.ConsumerConfig;
1818
import com.tencent.trpc.core.common.config.ProtocolConfig;
19+
import com.tencent.trpc.core.common.ShutdownListener;
1920
import com.tencent.trpc.core.exception.ErrorCode;
2021
import com.tencent.trpc.core.exception.TRpcException;
2122
import com.tencent.trpc.core.rpc.ConsumerInvoker;
@@ -100,6 +101,13 @@ public void test() throws Exception {
100101
}
101102

102103
manager.stop();
104+
105+
// Test internal shutdown listener
106+
ShutdownListener shutdownListener = manager.getShutdownListener();
107+
assertTrue(shutdownListener != null);
108+
109+
// Test shutdown listener functionality
110+
shutdownListener.onShutdown();
103111
}
104112

105113
private class TestClientCodec extends ClientCodec {

0 commit comments

Comments
 (0)