db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r326164 - in /incubator/jdo/trunk: api11/src/java/javax/jdo/spi/I18NHelper.java api20/src/java/javax/jdo/spi/I18NHelper.java
Date Tue, 18 Oct 2005 17:09:49 GMT
Author: clr
Date: Tue Oct 18 10:09:46 2005
New Revision: 326164

URL: http://svn.apache.org/viewcvs?rev=326164&view=rev
Log:
JDO-178 fix suggested by Marcin Owsiany

Modified:
    incubator/jdo/trunk/api11/src/java/javax/jdo/spi/I18NHelper.java
    incubator/jdo/trunk/api20/src/java/javax/jdo/spi/I18NHelper.java

Modified: incubator/jdo/trunk/api11/src/java/javax/jdo/spi/I18NHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/api11/src/java/javax/jdo/spi/I18NHelper.java?rev=326164&r1=326163&r2=326164&view=diff
==============================================================================
--- incubator/jdo/trunk/api11/src/java/javax/jdo/spi/I18NHelper.java (original)
+++ incubator/jdo/trunk/api11/src/java/javax/jdo/spi/I18NHelper.java Tue Oct 18 10:09:46 2005
@@ -236,7 +236,13 @@
 
         if (messages == null) //not found as loaded - add
         {
-            messages = ResourceBundle.getBundle(bundleName, locale, loader);
+            if (loader != null) {
+                messages = ResourceBundle.getBundle(bundleName, locale, loader);
+            } else {
+                // the JDO library is loaded by the boostrap class loader
+                messages = ResourceBundle.getBundle(bundleName, locale,
+                        getSystemClassLoaderPrivileged());
+            }
             bundles.put(bundleName, messages);
         }
         return messages;
@@ -374,5 +380,19 @@
     { 
         final int index = className.lastIndexOf('.');
         return ((index != -1) ? className.substring(0, index) : ""); // NOI18N
+    }
+
+    /**
+     * Get the system class loader. This must be done in a doPrivileged 
+     * block because of security.
+     */
+    private static ClassLoader getSystemClassLoaderPrivileged() {
+        return (ClassLoader) AccessController.doPrivileged (
+            new PrivilegedAction () {
+                public Object run () {
+                    return ClassLoader.getSystemClassLoader();
+                }
+            }
+        );
     }
 }

Modified: incubator/jdo/trunk/api20/src/java/javax/jdo/spi/I18NHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/spi/I18NHelper.java?rev=326164&r1=326163&r2=326164&view=diff
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/spi/I18NHelper.java (original)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/spi/I18NHelper.java Tue Oct 18 10:09:46 2005
@@ -236,7 +236,13 @@
 
         if (messages == null) //not found as loaded - add
         {
-            messages = ResourceBundle.getBundle(bundleName, locale, loader);
+            if (loader != null) {
+                messages = ResourceBundle.getBundle(bundleName, locale, loader);
+            } else {
+                // the JDO library is loaded by the boostrap class loader
+                messages = ResourceBundle.getBundle(bundleName, locale,
+                        getSystemClassLoaderPrivileged());
+            }
             bundles.put(bundleName, messages);
         }
         return messages;
@@ -374,5 +380,19 @@
     { 
         final int index = className.lastIndexOf('.');
         return ((index != -1) ? className.substring(0, index) : ""); // NOI18N
+    }
+
+    /**
+     * Get the system class loader. This must be done in a doPrivileged 
+     * block because of security.
+     */
+    private static ClassLoader getSystemClassLoaderPrivileged() {
+        return (ClassLoader) AccessController.doPrivileged (
+            new PrivilegedAction () {
+                public Object run () {
+                    return ClassLoader.getSystemClassLoader();
+                }
+            }
+        );
     }
 }



Mime
View raw message