Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#4 NullPointerException in statement cache

closed
nobody
None
5
2004-11-10
2004-11-09
ManfredHutt
No

There seems to be a multithreading problem in the
statement cache.
I'm using c3p0 0.8.4.5 together with Hibernate 2.1
When using the statement cache (setting
c3p0.max_statements to 10) and running a test that
calls a lot of times my "findUserByName" function from a
lot of parallel threads I sometimes get a
NullPointerException. According to the stack this seems
to be caused by some caching problems.
When setting the statement cache to 0 no Exception
comes.
Did you ever see such a problem?

Caused by: java.lang.NullPointerException
at
com.mchange.v2.c3p0.stmt.StatementCacheKey.equals
(StatementCacheKey.java:131)
at
com.mchange.v2.c3p0.stmt.ValueIdentityStatementCach
eKey$1.checkCoalesce
(ValueIdentityStatementCacheKey.java:50)
at
com.mchange.v2.coalesce.CoalesceIdenticator.identical
(CoalesceIdenticator.java:36)
at
com.mchange.v1.identicator.WeakIdHashKey.equals
(WeakIdHashKey.java:67)
at java.util.HashMap.eq(HashMap.java:274)
at java.util.HashMap.get(HashMap.java:323)
at com.mchange.v1.identicator.IdMap.get
(IdMap.java:51)
at
com.mchange.v1.identicator.IdWeakHashMap.get
(IdWeakHashMap.java:82)
at
com.mchange.v2.coalesce.AbstractWeakCoalescer.coales
ce(AbstractWeakCoalescer.java:41)
at
com.mchange.v2.c3p0.stmt.ValueIdentityStatementCach
eKey._find(ValueIdentityStatementCacheKey.java:160)
at
com.mchange.v2.c3p0.stmt.StatementCacheKey.find
(StatementCacheKey.java:48)
at
com.mchange.v2.c3p0.stmt.GooGooStatementCache.che
ckoutStatement(GooGooStatementCache.java:90)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnection$Proxy
ConnectionInvocationHandler.invoke
(C3P0PooledConnection.java:645)
at
com.mchange.v2.c3p0.impl.$Proxy5.prepareStatement
(Unknown Source)
at
net.sf.hibernate.impl.BatcherImpl.getPreparedStatement
(BatcherImpl.java:257)
at
net.sf.hibernate.impl.BatcherImpl.getPreparedStatement
(BatcherImpl.java:232)
at
net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement
(BatcherImpl.java:65)
at
net.sf.hibernate.loader.Loader.prepareQueryStatement
(Loader.java:779)
at net.sf.hibernate.loader.Loader.doQuery
(Loader.java:265)
at
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLa
zyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList
(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list
(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list
(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find
(SessionImpl.java:1544)
at net.sf.hibernate.impl.QueryImpl.list
(QueryImpl.java:39)
at
com.siemens.symphonia.domain.impl.DomainManagerImpl.f
indUserByName(DomainManagerImpl.java:185)
at
sun.reflect.GeneratedMethodAccessor26.invoke
(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke
(Method.java:324)
at
org.springframework.aop.framework.AopProxyUtils.invokeJ
oinpointUsingReflection(AopProxyUtils.java:61)
at
org.springframework.aop.framework.JdkDynamicAopProxy.i
nvoke(JdkDynamicAopProxy.java:143)
at $Proxy8.findUserByName(Unknown Source)

Discussion

  • Steve Waldman
    Steve Waldman
    2004-11-10

    Logged In: YES
    user_id=175530

    Yup. It's a bug. subclasses of StatementCacheKey explicitly rely on its
    static find() method being synchronized, which it was not. Fixed as of
    c3p0-0.8.5-pre8.

     
  • Steve Waldman
    Steve Waldman
    2004-11-10

    • status: open --> closed