Browse Source

Ensure at least 1 thread for thread pool.

Chuanyi Li L 7 years ago
parent
commit
1aa2e1a409

+ 2 - 2
parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlMultiStageCoprocessor.java

@@ -80,8 +80,8 @@ public class MysqlMultiStageCoprocessor extends AbstractCanalLifeCycle implement
         this.disruptorMsgBuffer = RingBuffer.createSingleProducer(new MessageEventFactory(),
         this.disruptorMsgBuffer = RingBuffer.createSingleProducer(new MessageEventFactory(),
             ringBufferSize,
             ringBufferSize,
             new BlockingWaitStrategy());
             new BlockingWaitStrategy());
-
-        this.parserExecutor = Executors.newFixedThreadPool(parserThreadCount,
+        int tc = parserThreadCount > 0 ? parserThreadCount : 1;
+        this.parserExecutor = Executors.newFixedThreadPool(tc,
             new NamedThreadFactory("MultiStageCoprocessor-Parser-" + destination));
             new NamedThreadFactory("MultiStageCoprocessor-Parser-" + destination));
 
 
         this.stageExecutor = Executors.newFixedThreadPool(2, new NamedThreadFactory("MultiStageCoprocessor-other-"
         this.stageExecutor = Executors.newFixedThreadPool(2, new NamedThreadFactory("MultiStageCoprocessor-other-"