Remove redundant code.

pull/192/head
Brett Wooldridge
parent cb38844e8a
commit b47d1dc105

@ -31,8 +31,6 @@ import javassist.LoaderClassPath;
import javassist.Modifier; import javassist.Modifier;
import javassist.NotFoundException; import javassist.NotFoundException;
import org.slf4j.LoggerFactory;
import com.zaxxer.hikari.util.ClassLoaderUtils; import com.zaxxer.hikari.util.ClassLoaderUtils;
/** /**
@ -56,8 +54,7 @@ public final class JavassistProxyFactory
proxyFactoryFactory.modifyProxyFactory(); proxyFactoryFactory.modifyProxyFactory();
} }
catch (Exception e) { catch (Exception e) {
LoggerFactory.getLogger(JavassistProxyFactory.class).error("Fatal exception during proxy generation", e); throw new RuntimeException("Fatal exception during proxy generation", e);
throw new RuntimeException(e);
} }
finally { finally {
Thread.currentThread().setContextClassLoader(contextClassLoader); Thread.currentThread().setContextClassLoader(contextClassLoader);
@ -73,13 +70,12 @@ public final class JavassistProxyFactory
// no-op // no-op
} }
private JavassistProxyFactory() private JavassistProxyFactory() throws Exception
{ {
classPool = new ClassPool(); classPool = new ClassPool();
classPool.importPackage("java.sql"); classPool.importPackage("java.sql");
classPool.appendClassPath(new LoaderClassPath(this.getClass().getClassLoader())); classPool.appendClassPath(new LoaderClassPath(this.getClass().getClassLoader()));
try {
// Connection is special, it has a checkClosed() call at the beginning // Connection is special, it has a checkClosed() call at the beginning
String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }";
generateProxyClass(Connection.class, ConnectionProxy.class, methodBody); generateProxyClass(Connection.class, ConnectionProxy.class, methodBody);
@ -93,10 +89,6 @@ public final class JavassistProxyFactory
generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody); generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody);
generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody); generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody);
} }
catch (Exception e) {
throw new RuntimeException(e);
}
}
private void modifyProxyFactory() throws Exception private void modifyProxyFactory() throws Exception
{ {
@ -185,10 +177,6 @@ public final class JavassistProxyFactory
} }
} }
if (Boolean.getBoolean("com.zaxxer.hikari.debug")) {
targetCt.debugWriteFile(System.getProperty("java.io.tmpdir"));
}
return targetCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain()); return targetCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain());
} }

@ -31,8 +31,6 @@ import javassist.LoaderClassPath;
import javassist.Modifier; import javassist.Modifier;
import javassist.NotFoundException; import javassist.NotFoundException;
import org.slf4j.LoggerFactory;
import com.zaxxer.hikari.util.ClassLoaderUtils; import com.zaxxer.hikari.util.ClassLoaderUtils;
/** /**
@ -56,8 +54,7 @@ public final class JavassistProxyFactory
proxyFactoryFactory.modifyProxyFactory(); proxyFactoryFactory.modifyProxyFactory();
} }
catch (Exception e) { catch (Exception e) {
LoggerFactory.getLogger(JavassistProxyFactory.class).error("Fatal exception during proxy generation", e); throw new RuntimeException("Fatal exception during proxy generation", e);
throw new RuntimeException(e);
} }
finally { finally {
Thread.currentThread().setContextClassLoader(contextClassLoader); Thread.currentThread().setContextClassLoader(contextClassLoader);
@ -73,13 +70,12 @@ public final class JavassistProxyFactory
// no-op // no-op
} }
private JavassistProxyFactory() private JavassistProxyFactory() throws Exception
{ {
classPool = new ClassPool(); classPool = new ClassPool();
classPool.importPackage("java.sql"); classPool.importPackage("java.sql");
classPool.appendClassPath(new LoaderClassPath(this.getClass().getClassLoader())); classPool.appendClassPath(new LoaderClassPath(this.getClass().getClassLoader()));
try {
// Connection is special, it has a checkClosed() call at the beginning // Connection is special, it has a checkClosed() call at the beginning
String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }";
generateProxyClass(Connection.class, ConnectionProxy.class, methodBody); generateProxyClass(Connection.class, ConnectionProxy.class, methodBody);
@ -93,10 +89,6 @@ public final class JavassistProxyFactory
generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody); generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody);
generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody); generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody);
} }
catch (Exception e) {
throw new RuntimeException(e);
}
}
private void modifyProxyFactory() throws Exception private void modifyProxyFactory() throws Exception
{ {
@ -186,10 +178,6 @@ public final class JavassistProxyFactory
} }
} }
if (Boolean.getBoolean("com.zaxxer.hikari.debug")) {
targetCt.debugWriteFile(System.getProperty("java.io.tmpdir"));
}
return targetCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain()); return targetCt.toClass(classPool.getClassLoader(), getClass().getProtectionDomain());
} }

Loading…
Cancel
Save