Jialin Qiao created IOTDB-573:
---------------------------------
Summary: Construct AbstractIoTDBThread and catch all Exception
Key: IOTDB-573
URL: https://issues.apache.org/jira/browse/IOTDB-573
Project: Apache IoTDB
Issue Type: Improvement
Components: Core/Engine
Reporter: Jialin Qiao
Hi, in current IoTDB codes, threads are created without any constraints.
RuntimeExceptions are not caught in the run method. Therefore, we usually miss
the stack information and only get a NullPointerException in the parent thread.
Therefore, we need a base thread AbstractIoTDBThread that manages all threads.
In the IoTDBThead, all exceptions are caught and logged. Here is an example.
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractIoTDBThread<T> implements Callable<T> {
protected Logger logger = null;
public AbstractIoTDBThread() {
initLogger();
}
@Override
public T call() throws Exception {
try {
return internalRun();
} catch (Exception e) {
logger.error("Meet error in sub thread", e);
throw e;
}
}
abstract void initLogger();
abstract T internalRun();
}
class MyThread extends AbstractIoTDBThread<Long> {
@Override
void initLogger() {
logger = LoggerFactory.getLogger(MyThread.class);
}
@Override
Long internalRun() {
return 0L;
}
}
This issue contains two tasks:
(1) Create and enrich AbstractIoTDBThread
(2) Make all threads in IoTDB to extend AbstractIoTDBThread.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)