You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2016/08/30 19:49:02 UTC
svn commit: r1758451 -
/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/InternationalizedRuntimeException.java
Author: schor
Date: Tue Aug 30 19:49:01 2016
New Revision: 1758451
URL: http://svn.apache.org/viewvc?rev=1758451&view=rev
Log:
[UIMA-5085] also make use of the stack-climbing class loader to find the bundle.
Modified:
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/InternationalizedRuntimeException.java
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/InternationalizedRuntimeException.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/InternationalizedRuntimeException.java?rev=1758451&r1=1758450&r2=1758451&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/InternationalizedRuntimeException.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/InternationalizedRuntimeException.java Tue Aug 30 19:49:01 2016
@@ -23,6 +23,8 @@ import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
+import org.apache.uima.internal.util.I18nUtil;
+
/**
* The <code>InternationalizedRuntimeException</code> class adds internationalization support to
* the standard functionality provided by <code>java.lang.RuntimeException</code>. Because this
@@ -72,6 +74,11 @@ public class InternationalizedRuntimeExc
private Throwable mCause;
/**
+ * the thread local class loader at creation time, see UIMA-4793
+ */
+ final private ClassLoader originalContextClassLoader;
+
+ /**
* Creates a new <code>InternationalizedRuntimeException</code> with a null message.
*/
public InternationalizedRuntimeException() {
@@ -128,6 +135,7 @@ public class InternationalizedRuntimeExc
public InternationalizedRuntimeException(String aResourceBundleName, String aMessageKey,
Object[] aArguments, Throwable aCause) {
super();
+ originalContextClassLoader = Thread.currentThread().getContextClassLoader();
mCause = aCause;
mResourceBundleName = aResourceBundleName;
mMessageKey = aMessageKey;
@@ -218,20 +226,25 @@ public class InternationalizedRuntimeExc
return null;
try {
- // locate the resource bundle for this exception's messages
- ResourceBundle bundle = ResourceBundle.getBundle(getResourceBundleName(), aLocale);
- // retrieve the message from the resource bundle
- String message = bundle.getString(getMessageKey());
- // if arguments exist, use MessageFormat to include them
- if (getArguments().length > 0) {
- MessageFormat fmt = new MessageFormat(message);
- fmt.setLocale(aLocale);
- return fmt.format(getArguments());
- } else
- return message;
- } catch (Exception e) {
- return "EXCEPTION MESSAGE LOCALIZATION FAILED: " + e.toString();
- }
+ I18nUtil.setTccl(originalContextClassLoader);
+ return I18nUtil.localizeMessage(getResourceBundleName(), aLocale, getMessageKey(), getArguments());
+ } finally {
+ I18nUtil.removeTccl();
+ }
+// // locate the resource bundle for this exception's messages
+// ResourceBundle bundle = ResourceBundle.getBundle(getResourceBundleName(), aLocale);
+// // retrieve the message from the resource bundle
+// String message = bundle.getString(getMessageKey());
+// // if arguments exist, use MessageFormat to include them
+// if (getArguments().length > 0) {
+// MessageFormat fmt = new MessageFormat(message);
+// fmt.setLocale(aLocale);
+// return fmt.format(getArguments());
+// } else
+// return message;
+// } catch (Exception e) {
+// return "EXCEPTION MESSAGE LOCALIZATION FAILED: " + e.toString();
+// }
}
/**