H2 + Jetty + Android issues - java.sql.DriverManager.getDrivers can throw a java.util.ConcurrentModificationException -
i hope can give insight bizarre issue
i have ijetty webapp on android device. have ability clear our h2 db after user shuts down jetty server dalvik vm online.
i exception after following case: 1. start server 2. login system (this creates h2 db if not there, , connections made) 3. stop server (this issues disconnect connections db) 4. delete h2 db app (this deletes h2 db file) 5. start app 6. login system (this creates h2 db if not there, , connections made)
things work fine when twice. when on third time exception:
java.lang.exceptionininitializererror . . . caused by: java.util.concurrentmodificationexception @ java.util.arraylist$arraylistiterator.next(arraylist.java:569) @ java.sql.drivermanager.getdrivers(drivermanager.java:258) @ org.apache.commons.dbcp.basicdatasource.<clinit>(basicdatasource.java:57) ... 41 more notes on issue:
- we don't init actual datasource in spring @ all. call in java:
basicdatasource datasource = new basicdatasource();whenever new connection needs made. - when jetty server goes down tried issueing sql command "shutdown" did not change anything.
- looking @ code drivermanager confused how exception happen. synchronized on arraylist iterating over.
- i posted issue on h2 forum check if notice it. don't think h2 specific thing. (https://groups.google.com/forum/#!topic/h2-database/oikngnyjosm)
any thoughts appreciated
update below call andorid's drivermanager.java api 17 (it happens in 18 well). if can find link repo post that
/** * returns {@code enumeration} contains of loaded jdbc * drivers current caller can access. * * @return {@code enumeration} containing loaded jdbc * {@code drivers}. */ public static enumeration<driver> getdrivers() { /* * synchronize avoid clashes additions , removals of drivers * in driverset */ classloader callerclassloader = vmstack.getcallingclassloader(); synchronized (thedrivers) { arraylist<driver> result = new arraylist<driver>(); (driver driver : thedrivers) { // offending line if (drivermanager.isclassfromclassloader(driver, callerclassloader)) { result.add(driver); } } return collections.enumeration(result); } }
Comments
Post a Comment