Menu

#11 concurrent modification at conn.close()

open
nobody
None
5
2001-11-08
2001-11-08
No

I just started using 2.1 from CVS and now I get the
following error:

java.util.ConcurrentModificationException at
java.util.HashMap$HashIterator.next(HashMap.java:736)
at java.util.WeakHashMap$1.hasNext
(WeakHashMap.java:369) at
java.util.AbstractMap$2.hasNext(AbstractMap.java:364)
at com.codestudio.sql.PoolManConnection.clean
(PoolManConnection.java:128) at
com.codestudio.util.JDBCPool.returnConnection
(JDBCPool.java:378) at
com.codestudio.util.JDBCPool.connectionClosed
(JDBCPool.java:216) at
com.codestudio.sql.PoolManConnection.sendCloseEvent
(PoolManConnection.java:180) at
com.codestudio.sql.PoolManConnectionHandle.close
(PoolManConnectionHandle.java:55) at

This happens as I call conn.close() at the end of my
jsp page.

Discussion

  • Jason Swartz

    Jason Swartz - 2001-12-16

    Logged In: YES
    user_id=69061

    This is also happening to me, on RH Linux 7.1 with java
    1.3.1-b24.

     
  • Nobody/Anonymous

    Logged In: NO

    Same thing with :
    Win NT
    Poolman 2.1B1
    jdk 1.3.1
    oracle thin jdbc drivers 8.1.7

     
  • Nobody/Anonymous

    Logged In: NO

    this is because you have open two more statement and
    unclosed them when you close the connection.

    here is the test program.

    String sDriver = "com.codestudio.sql.PoolMan";
    String sURL = "jdbc:poolman";

    try {
    Class.forName(sDriver).newInstance() ;
    conn = DriverManager.getConnection(sURL);

    stmt = conn.createStatement();
    stmt = conn.createStatement();
    } catch (Exception se) {
    cat.debug("Exception occured.", se);
    } finally {
    try {
    conn.close(); // Exception occured.
    } catch(SQLException se) {
    }
    }

     
  • Jason Swartz

    Jason Swartz - 2001-12-29

    Logged In: YES
    user_id=69061

    Yup, I wasn't closing all my statements. When I fixed that,
    this error went away. Thanks to nobody! Well, it'd be nice if
    poolman could report this problem and handle it safely.

     
  • Bert Summers

    Bert Summers - 2002-01-04

    Logged In: YES
    user_id=219308

    Call me crazy but I thought that when I closed the
    connection that the statements would get closed for me.

     
  • Nobody/Anonymous

    Logged In: NO

    The problem is in PoolManConnection.clean(). A fix follows:

    for (Iterator iter = openstatements.iterator(); iter.hasNext
    ();)
    {
    // automatically cleans open ResultSets as well
    PoolManStatement sst = (PoolManStatement) iter.next();
    iter.remove(); // add this to fix
    //sst.clean(); // don't need this (the following line
    will do the clean)
    // The following line calls back to
    removeOpenStatement,
    // which will alter the openstatements map and cause a
    // ConcurrentModificationException here if we haven't
    // Already removed the statement.
    JDBCPool.closeStatement(sst);
    }

     

Log in to post a comment.

MongoDB Logo MongoDB