yugong 首次启动,queue为null,导致NullPointerException

yebdmbv4  于 2021-11-29  发布在  Java
关注(0)|答案(2)|浏览(403)

OracleFullRecordExtractor类 #start方法 中第77行代码:queue = new LinkedBlockingQueue<>(context.getOnceCrawNum() * 2);
假如放在71行之后,

71行-77行代码:

71 extractorThread = new NamedThreadFactory(this.getClass().getSimpleName() + "-"
72 + context.getTableMeta().getFullName()).newThread(new
73 ContinueExtractor(this,
74 context,
75 queue));
76 extractorThread.start();
77 queue = new LinkedBlockingQueue<>(context.getOnceCrawNum() * 2);

首次启动会导致:
ContinueExtractor类 #run方法时,127行代码queue为null:于是 NullPointerException: null

(调整77行代码顺序之后,可解决问题)

127行代码:

for (Record record : result) {
try {
127 queue.put(record);
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 传递
throw new YuGongException(e);
}
}

2018-12-29 09:56:38.438 [OracleFullRecordExtractor-ZHEJIANGGRID5.YUGONG_EXAMPLE_JOIN-0] ERROR com.taobao.yugong.common.utils.thread.NamedThreadFactory - uncaught exception
java.lang.NullPointerException: null
at com.taobao.yugong.extractor.ContinueExtractor.lambda$run$1(ContinueExtractor.java:127) ~[classes/:na]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:591) ~[spring-2.5.6.jar:2.5.6]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:619) ~[spring-2.5.6.jar:2.5.6]
at com.taobao.yugong.extractor.ContinueExtractor.run(ContinueExtractor.java:92) ~[classes/:na]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_152]
2018-12-29 09:57:38.017 [pool-3-thread-2] INFO com.taobao.yugong.common.stats.ProgressTracer - {未启动:0,全量中:1,增量中:0,已追上:0,异常数:0}
2018-12-29 09:57:38.018 [pool-3-thread-2] INFO com.taobao.yugong.common.stats.ProgressTracer - 全量中:[ZHEJIANGGRID5.YUGONG_EXAMPLE_JOIN]
2018-12-29 09:57:38.018 [pool-3-thread-2] INFO com.taobao.yugong.common.stats.ProgressTracer - 已完成:[]

fzsnzjdm

fzsnzjdm1#

感谢,问题解决了。把77行代码改成71行之前就可以了。

eufgjt7s

eufgjt7s2#

我也遇到了,源码得改过来

相关问题