ha-jdbc/ha-jdbc — pull request #15 by sjones4 (2013-07-07 06:30:42+00:00)
Title: Cache ExceptionFactory per ExceptionType.

AbstractInvocationHandler can have poor performance due to look up of the ExceptionFactory on each invocation causing classpath scanning for relevant service implementations:

```
java.lang.Thread.State: RUNNABLE
at java.util.zip.ZipFile.getEntry(Native Method)
at java.util.zip.ZipFile.getEntry(ZipFile.java:304)
- locked <0x00000000c4ef7928> (a java.util.jar.JarFile)
at java.util.jar.JarFile.getEntry(JarFile.java:226)
at java.util.jar.JarFile.getJarEntry(JarFile.java:209)
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:817)
at sun.misc.URLClassPath$JarLoader.findResource(URLClassPath.java:795)
at sun.misc.URLClassPath$1.next(URLClassPath.java:222)
at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:232)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:583)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:581)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader$3.next(URLClassLoader.java:580)
at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:605)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:346)
at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:439)
at net.sf.hajdbc.util.ServiceLoaders.findService(ServiceLoaders.java:55)
at net.sf.hajdbc.util.ServiceLoaders.findRequiredService(ServiceLoaders.java:73)
at net.sf.hajdbc.ExceptionType.getExceptionFactory(ExceptionType.java:51)
at net.sf.hajdbc.ExceptionType.getExceptionFactory(ExceptionType.java:60)
at net.sf.hajdbc.sql.AbstractInvocationHandler.getExceptionFactory(AbstractInvocationHandler.java:390)
at net.sf.hajdbc.sql.AbstractInvocationHandler$SimpleInvoker.invoke(AbstractInvocationHandler.java:414)
```

This pull request adds caching so the work is performed once per type.