New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible occur NullpointerException on MyBatisCursorItemReader when close #237

Closed
kazuki43zoo opened this Issue Oct 10, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@kazuki43zoo
Member

kazuki43zoo commented Oct 10, 2017

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;
}

@kazuki43zoo kazuki43zoo added the bug label Oct 10, 2017

@kazuki43zoo kazuki43zoo added this to the 1.3.2 milestone Oct 10, 2017

kazuki43zoo added a commit to kazuki43zoo/spring that referenced this issue Oct 10, 2017

@kazuki43zoo kazuki43zoo self-assigned this Oct 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment