From 27e8bd48497f9c6ee92e65cc9cf1a0f830ff362a Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Fri, 6 Oct 2006 17:57:23 +0000 Subject: [PATCH] Handle exceptions in getFactoryClass() when it is just being used for inclusion in the error message of an exception. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@453712 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/openjpa/kernel/Bootstrap.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java index 251290909..cade0adbb 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java @@ -60,10 +60,10 @@ public class Bootstrap { if (cause instanceof OpenJPAException) throw (OpenJPAException) cause; throw new InternalException(s_loc.get("new-brokerfactory-excep", - getFactoryClass(conf, loader)), cause); + getFactoryClassName(conf, loader)), cause); } catch (Exception e) { throw new UserException(s_loc.get("bad-new-brokerfactory", - getFactoryClass(conf, loader)), e).setFatal(true); + getFactoryClassName(conf, loader)), e).setFatal(true); } } @@ -88,10 +88,10 @@ public class Bootstrap { if (cause instanceof OpenJPAException) throw (OpenJPAException) cause; throw new InternalException(s_loc.get("brokerfactory-excep", - getFactoryClass(conf, loader)), cause); + getFactoryClassName(conf, loader)), cause); } catch (Exception e) { throw new UserException(s_loc.get("bad-brokerfactory", - getFactoryClass(conf, loader)), e).setFatal(true); + getFactoryClassName(conf, loader)), e).setFatal(true); } } @@ -117,6 +117,15 @@ public class Bootstrap { return (BrokerFactory) meth.invoke(null, new Object[]{ conf }); } + private static String getFactoryClassName(ConfigurationProvider conf, + ClassLoader loader) { + try { + return getFactoryClass(conf, loader).getName(); + } catch (Exception e) { + return "<" + e.toString() + ">"; + } + } + /** * Instantiate the factory class designated in properties. */