Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
3.0 Beta 7
-
None
Description
Some times we have a NullPointerException :
java.lang.NullPointerException at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:61) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:18)
The problem is related to the ScheduledCache cleaning.
In method query of CachingExecutor class we have :
[...] if (cache.hasKey(key)) { return (List) cache.getObject(key); } else { [...] }
both methods cache.hasKey() and cache.getObject() of class org.apache.ibatis.cache.decorators.ScheduledCache are checking the cleaning interval by calling {{clearWhenStale()}.
Problem arrive when the timeout occur after the call to cache.hasKey()} but BEFORE the call to {{cache.getObject().
To reproduce the case, define a cache of type LRU with a small flushInterval (for exemple 10ms) and loop on a simple select query.