You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2014/08/18 07:39:01 UTC
git commit: [OPTIQ-377] UnregisteredDriver should catch,
log and re-throw NoClassDefFoundError
Repository: incubator-optiq
Updated Branches:
refs/heads/master 3055cc32f -> b2aeee464
[OPTIQ-377] UnregisteredDriver should catch, log and re-throw NoClassDefFoundError
Project: http://git-wip-us.apache.org/repos/asf/incubator-optiq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-optiq/commit/b2aeee46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-optiq/tree/b2aeee46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-optiq/diff/b2aeee46
Branch: refs/heads/master
Commit: b2aeee4644a787bf19732dc203a708c5b1a533f9
Parents: 3055cc3
Author: Julian Hyde <ju...@gmail.com>
Authored: Sun Aug 17 22:22:25 2014 -0700
Committer: Julian Hyde <ju...@gmail.com>
Committed: Sun Aug 17 22:22:25 2014 -0700
----------------------------------------------------------------------
.../net/hydromatic/avatica/UnregisteredDriver.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/b2aeee46/avatica/src/main/java/net/hydromatic/avatica/UnregisteredDriver.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/net/hydromatic/avatica/UnregisteredDriver.java b/avatica/src/main/java/net/hydromatic/avatica/UnregisteredDriver.java
index aab532b..dd2c0ff 100644
--- a/avatica/src/main/java/net/hydromatic/avatica/UnregisteredDriver.java
+++ b/avatica/src/main/java/net/hydromatic/avatica/UnregisteredDriver.java
@@ -18,6 +18,7 @@ package net.hydromatic.avatica;
import java.sql.*;
import java.util.*;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -106,14 +107,23 @@ public abstract class UnregisteredDriver implements java.sql.Driver {
final Class<?> clazz = Class.forName(factoryClassName);
return (AvaticaFactory) clazz.newInstance();
} catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
+ throw handle("Error loading factory " + factoryClassName, e);
} catch (IllegalAccessException e) {
- throw new RuntimeException(e);
+ throw handle("Error loading factory " + factoryClassName, e);
} catch (InstantiationException e) {
- throw new RuntimeException(e);
+ throw handle("Error loading factory " + factoryClassName, e);
+ } catch (Throwable e) {
+ // It is not usually good to catch Throwable. But class loading can fail
+ // with serious errors such as java.lang.NoClassDefFoundError
+ throw handle("Error loading factory " + factoryClassName, e);
}
}
+ private static RuntimeException handle(String msg, Throwable e) {
+ Logger.getLogger("").log(Level.SEVERE, msg, e);
+ throw new RuntimeException(msg, e);
+ }
+
public Connection connect(String url, Properties info) throws SQLException {
if (!acceptsURL(url)) {
return null;