Closed
Description
In the current implementation of MyBatisCursorItemReader
, there is possible that NullpointerException
occurs when implements application code as follow:
Application code:
try {
reader.open(...);
// ...
} finally {
reader.close();
}
MyBatisCursorItemReader:
@Override
protected void doOpen() throws Exception {
Map<String, Object> parameters = new HashMap<>();
if (parameterValues != null) {
parameters.putAll(parameterValues);
}
sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE);
cursor = sqlSession.selectCursor(queryId, parameters); // <- when occurs exception, a cursor is null
cursorIterator = cursor.iterator();
}
@Override
protected void doClose() throws Exception {
cursor.close(); // <- occurs NullpointerException
sqlSession.close();
cursorIterator = null;
}