funky-eyes commented on code in PR #7783:
URL: https://github.com/apache/incubator-seata/pull/7783#discussion_r2532464027
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -120,17 +127,18 @@ public abstract class AbstractNettyRemotingClient extends
AbstractNettyRemoting
@Override
public void init() {
- timerExecutor.scheduleAtFixedRate(
- () -> {
- try {
-
clientChannelManager.reconnect(getTransactionServiceGroup());
- } catch (Exception ex) {
- LOGGER.warn("reconnect server failed. {}",
ex.getMessage());
- }
- },
- SCHEDULE_DELAY_MILLS,
- SCHEDULE_INTERVAL_MILLS,
- TimeUnit.MILLISECONDS);
+ if (timerStarted.compareAndSet(false, true)) {
+ mergeLock.lock();
+ try {
+ this.reconnectTimer = new ScheduledThreadPoolExecutor(
+ 1, new NamedThreadFactory("Reconnect-Timer-" +
transactionRole.name(), 1));
+ this.reconnectTimer.scheduleAtFixedRate(
+ this.reconnectTask, SCHEDULE_DELAY_MILLS,
SCHEDULE_INTERVAL_MILLS, TimeUnit.MILLISECONDS);
Review Comment:
reconnectTask is still null at this point; you should initialize
reconnectTask before creating the thread pool. Also, why not reuse
timerExecutor instead of creating a new scheduled thread pool?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]