tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1570516 - in /tomcat/tc7.0.x/trunk: ./ java/javax/el/
Date Fri, 21 Feb 2014 10:39:16 GMT
Author: markt
Date: Fri Feb 21 10:39:15 2014
New Revision: 1570516

URL: http://svn.apache.org/r1570516
Log:
Backport some EL refactoring in preparation for the fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=56147

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/javax/el/ArrayELResolver.java
    tomcat/tc7.0.x/trunk/java/javax/el/BeanELResolver.java
    tomcat/tc7.0.x/trunk/java/javax/el/ELResolver.java
    tomcat/tc7.0.x/trunk/java/javax/el/ListELResolver.java
    tomcat/tc7.0.x/trunk/java/javax/el/MapELResolver.java
    tomcat/tc7.0.x/trunk/java/javax/el/ResourceBundleELResolver.java
    tomcat/tc7.0.x/trunk/java/javax/el/Util.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1499371

Modified: tomcat/tc7.0.x/trunk/java/javax/el/ArrayELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/ArrayELResolver.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/ArrayELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/ArrayELResolver.java Fri Feb 21 10:39:15 2014
@@ -86,7 +86,7 @@ public class ArrayELResolver extends ELR
             context.setPropertyResolved(true);
 
             if (this.readOnly) {
-                throw new PropertyNotWritableException(message(context,
+                throw new PropertyNotWritableException(Util.message(context,
                         "resolverNotWriteable", new Object[] { base.getClass()
                                 .getName() }));
             }
@@ -95,7 +95,7 @@ public class ArrayELResolver extends ELR
             checkBounds(base, idx);
             if (value != null && !Util.isAssignableFrom(value.getClass(),
                     base.getClass().getComponentType())) {
-                throw new ClassCastException(message(context,
+                throw new ClassCastException(Util.message(context,
                         "objectNotAssignable",
                         new Object[] {value.getClass().getName(),
                         base.getClass().getComponentType().getName()}));

Modified: tomcat/tc7.0.x/trunk/java/javax/el/BeanELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/BeanELResolver.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/BeanELResolver.java Fri Feb 21 10:39:15 2014
@@ -95,7 +95,7 @@ public class BeanELResolver extends ELRe
             if (cause instanceof VirtualMachineError) {
                 throw (VirtualMachineError) cause;
             }
-            throw new ELException(message(context, "propertyReadError",
+            throw new ELException(Util.message(context, "propertyReadError",
                     new Object[] { base.getClass().getName(),
                             property.toString() }), cause);
         } catch (Exception e) {
@@ -132,7 +132,7 @@ public class BeanELResolver extends ELRe
         context.setPropertyResolved(true);
 
         if (this.readOnly) {
-            throw new PropertyNotWritableException(message(context,
+            throw new PropertyNotWritableException(Util.message(context,
                     "resolverNotWriteable", new Object[] { base.getClass()
                             .getName() }));
         }
@@ -150,7 +150,7 @@ public class BeanELResolver extends ELRe
             if (cause instanceof VirtualMachineError) {
                 throw (VirtualMachineError) cause;
             }
-            throw new ELException(message(context, "propertyWriteError",
+            throw new ELException(Util.message(context, "propertyWriteError",
                     new Object[] { base.getClass().getName(),
                             property.toString() }), cause);
         } catch (Exception e) {
@@ -226,7 +226,7 @@ public class BeanELResolver extends ELRe
         private BeanProperty get(ELContext ctx, String name) {
             BeanProperty property = this.properties.get(name);
             if (property == null) {
-                throw new PropertyNotFoundException(message(ctx,
+                throw new PropertyNotFoundException(Util.message(ctx,
                         "propertyNotFound",
                         new Object[] { type.getName(), name }));
             }
@@ -282,7 +282,7 @@ public class BeanELResolver extends ELRe
             if (this.write == null) {
                 this.write = getMethod(this.owner, descriptor.getWriteMethod());
                 if (this.write == null) {
-                    throw new PropertyNotFoundException(message(ctx,
+                    throw new PropertyNotFoundException(Util.message(ctx,
                             "propertyNotWritable", new Object[] {
                                     owner.getName(), descriptor.getName() }));
                 }
@@ -294,7 +294,7 @@ public class BeanELResolver extends ELRe
             if (this.read == null) {
                 this.read = getMethod(this.owner, descriptor.getReadMethod());
                 if (this.read == null) {
-                    throw new PropertyNotFoundException(message(ctx,
+                    throw new PropertyNotFoundException(Util.message(ctx,
                             "propertyNotReadable", new Object[] {
                                     owner.getName(), descriptor.getName() }));
                 }

Modified: tomcat/tc7.0.x/trunk/java/javax/el/ELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/ELResolver.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/ELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/ELResolver.java Fri Feb 21 10:39:15 2014
@@ -14,42 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package javax.el;
 
-import java.text.MessageFormat;
 import java.util.Iterator;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
 /**
  * @author Jacob Hookom [jacob/hookom.net]
  *
  */
 public abstract class ELResolver {
-    
-    static String message(ELContext context, String name, Object[] props) {
-        Locale locale = context.getLocale();
-        if (locale == null) {
-            locale = Locale.getDefault();
-            if (locale == null) {
-                return "";
-            }
-        }
-        ResourceBundle bundle = ResourceBundle.getBundle(
-                "javax.el.LocalStrings", locale);
-        try {
-            String template = bundle.getString(name);
-            if (props != null) {
-                template = MessageFormat.format(template, props);
-            }
-            return template;
-        } catch (MissingResourceException e) {
-            return "Missing Resource: '" + name + "' for Locale "
-                    + locale.getDisplayName();
-        }
-    }
 
     public static final String RESOLVABLE_AT_DESIGN_TIME = "resolvableAtDesignTime";
     

Modified: tomcat/tc7.0.x/trunk/java/javax/el/ListELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/ListELResolver.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/ListELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/ListELResolver.java Fri Feb 21 10:39:15 2014
@@ -94,7 +94,7 @@ public class ListELResolver extends ELRe
             List<Object> list = (List<Object>) base;
 
             if (this.readOnly) {
-                throw new PropertyNotWritableException(message(context,
+                throw new PropertyNotWritableException(Util.message(context,
                         "resolverNotWriteable", new Object[] { base.getClass()
                                 .getName() }));
             }

Modified: tomcat/tc7.0.x/trunk/java/javax/el/MapELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/MapELResolver.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/MapELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/MapELResolver.java Fri Feb 21 10:39:15 2014
@@ -83,7 +83,7 @@ public class MapELResolver extends ELRes
             context.setPropertyResolved(true);
 
             if (this.readOnly) {
-                throw new PropertyNotWritableException(message(context,
+                throw new PropertyNotWritableException(Util.message(context,
                         "resolverNotWriteable", new Object[] { base.getClass()
                                 .getName() }));
             }

Modified: tomcat/tc7.0.x/trunk/java/javax/el/ResourceBundleELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/ResourceBundleELResolver.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/ResourceBundleELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/ResourceBundleELResolver.java Fri Feb 21 10:39:15 2014
@@ -81,7 +81,7 @@ public class ResourceBundleELResolver ex
         
         if (base instanceof ResourceBundle) {
             context.setPropertyResolved(true);
-            throw new PropertyNotWritableException(message(context,
+            throw new PropertyNotWritableException(Util.message(context,
                     "resolverNotWriteable", new Object[] { base.getClass()
                             .getName() }));
         }

Modified: tomcat/tc7.0.x/trunk/java/javax/el/Util.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/javax/el/Util.java?rev=1570516&r1=1570515&r2=1570516&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/javax/el/Util.java (original)
+++ tomcat/tc7.0.x/trunk/java/javax/el/Util.java Fri Feb 21 10:39:15 2014
@@ -16,8 +16,53 @@
  */
 package javax.el;
 
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
 class Util {
 
+    /**
+     * Checks whether the supplied Throwable is one that needs to be
+     * rethrown and swallows all others.
+     * @param t the Throwable to check
+     */
+    static void handleThrowable(Throwable t) {
+        if (t instanceof ThreadDeath) {
+            throw (ThreadDeath) t;
+        }
+        if (t instanceof VirtualMachineError) {
+            throw (VirtualMachineError) t;
+        }
+        // All other instances of Throwable will be silently swallowed
+    }
+
+    static String message(ELContext context, String name, Object... props) {
+        Locale locale = null;
+        if (context != null) {
+            locale = context.getLocale();
+        }
+        if (locale == null) {
+            locale = Locale.getDefault();
+            if (locale == null) {
+                return "";
+            }
+        }
+        ResourceBundle bundle = ResourceBundle.getBundle(
+                "javax.el.LocalStrings", locale);
+        try {
+            String template = bundle.getString(name);
+            if (props != null) {
+                template = MessageFormat.format(template, props);
+            }
+            return template;
+        } catch (MissingResourceException e) {
+            return "Missing Resource: '" + name + "' for Locale "
+                    + locale.getDisplayName();
+        }
+    }
+
     /*
      * This method duplicates code in org.apache.el.util.ReflectionUtil. When
      * making changes keep the code in sync.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message