as Map key, not the DbSource instance. Using the instance as key is both inefficient and
error prone (see fd0b77bc11).
Additional changes:
- modified getConnection() to check if the DB is oracle. "SELECT 1" is invalid
for Oracle DBs and lead to Helma dropping in-use connections every minute.
- set DbSource name final
The source of the deadlock problem seems that during DbSource.getConnection() ResourceProperties instances are compared using their equals() method, which is synchronized in Hashtable and can/does lead to deadlocks (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6582568).
This commit overwrites equals with an unsynchronized version. Note that this implementation might return a wrong result if one of the two instances is modified during this method call, but at least doesn't throw a ConcurrentModificationException.
the statistics of a cache instance for an application can be retrieved
by calling `app.__app__.getCacheStatistics()`. That's not very useful for the
default `ObjectCache` but essential for looking into what more complex cache
impls like `SwarmCache` do
we could remove all the other cache statistics methods like `getCacheUsage`
and output that info in the map returned by `getCacheStatistics()`
i had to bump java to 1.5 for the generics.. if that's a problem we can
remove the generics
one of our apps was stuck in a deadlock in ResourceProperties.size(),
see excerpt of the stack trace below. this fix synchronizes various overriding
methods since they are synchronized in Hashtable as well.
removed superfluous toString method too.
```
"app-230":
at java.util.Hashtable.size(Hashtable.java:206)
- waiting to lock <0xa13f8548> (a helma.util.ResourceProperties)
at helma.util.ResourceProperties.size(ResourceProperties.java:529)
at java.util.Hashtable.equals(Hashtable.java:742)
- locked <0xa1065708> (a helma.util.ResourceProperties)
at helma.objectmodel.db.DbSource.equals(DbSource.java:292)
...
"app-439":
at java.util.Hashtable.size(Hashtable.java:206)
- waiting to lock <0xa1065708> (a helma.util.ResourceProperties)
at helma.util.ResourceProperties.size(ResourceProperties.java:529)
at java.util.Hashtable.equals(Hashtable.java:742)
- locked <0xa13f8548> (a helma.util.ResourceProperties)
at helma.objectmodel.db.DbSource.equals(DbSource.java:292)
...
```
i switched the order of app-binding and jetty-server-starting; now it
gets a bit farther but throws another exception:
2012-03-20 10:25:35.550:WARN:oejuc.AbstractLifeCycle:FAILED org.eclipse.jetty.servlet.ServletHandler@177f409c: java.lang.ClassCastException: org.eclipse.jetty.server.handler.ContextHandler cannot be cast to org.eclipse.jetty.servlet.ServletContextHandler
java.lang.ClassCastException: org.eclipse.jetty.server.handler.ContextHandler cannot be cast to org.eclipse.jetty.servlet.ServletContextHandler
at org.eclipse.jetty.servlet.ServletHandler.doStart(ServletHandler.java:147)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.handler.ScopedHandler.doStart(ScopedHandler.java:97)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:722)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:676)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at helma.main.ApplicationManager$AppDescriptor.bind(ApplicationManager.java:550)
at helma.main.ApplicationManager.startAll(ApplicationManager.java:168)
at helma.main.Server.run(Server.java:602)
at java.lang.Thread.run(Thread.java:662)
helma compiles & starts now, but throws this exception:
java.lang.IllegalStateException: STARTED
at org.eclipse.jetty.server.handler.HandlerWrapper.setHandler(HandlerWrapper.java:71)
at helma.main.ApplicationManager$AppDescriptor.bind(ApplicationManager.java:482)
at helma.main.ApplicationManager.startAll(ApplicationManager.java:168)
at helma.main.Server.run(Server.java:611)
at java.lang.Thread.run(Thread.java:662)