tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1353125 - in /tomcat/trunk: java/javax/el/BeanELResolver.java test/javax/el/TestBeanELResolver.java
Date Sat, 23 Jun 2012 13:17:06 GMT
Author: markt
Date: Sat Jun 23 13:17:06 2012
New Revision: 1353125

URL: http://svn.apache.org/viewvc?rev=1353125&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53421
Provide more useful error message when bean property getter/setter cannot be found.

Added:
    tomcat/trunk/test/javax/el/TestBeanELResolver.java   (with props)
Modified:
    tomcat/trunk/java/javax/el/BeanELResolver.java

Modified: tomcat/trunk/java/javax/el/BeanELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1353125&r1=1353124&r2=1353125&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/BeanELResolver.java (original)
+++ tomcat/trunk/java/javax/el/BeanELResolver.java Sat Jun 23 13:17:06 2012
@@ -292,7 +292,7 @@ public class BeanELResolver extends ELRe
                 if (this.write == null) {
                     throw new PropertyNotFoundException(message(ctx,
                             "propertyNotWritable", new Object[] {
-                                    type.getName(), descriptor.getName() }));
+                                    owner.getName(), descriptor.getName() }));
                 }
             }
             return this.write;
@@ -304,7 +304,7 @@ public class BeanELResolver extends ELRe
                 if (this.read == null) {
                     throw new PropertyNotFoundException(message(ctx,
                             "propertyNotReadable", new Object[] {
-                                    type.getName(), descriptor.getName() }));
+                                    owner.getName(), descriptor.getName() }));
                 }
             }
             return this.read;

Added: tomcat/trunk/test/javax/el/TestBeanELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestBeanELResolver.java?rev=1353125&view=auto
==============================================================================
--- tomcat/trunk/test/javax/el/TestBeanELResolver.java (added)
+++ tomcat/trunk/test/javax/el/TestBeanELResolver.java Sat Jun 23 13:17:06 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.el;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import org.apache.jasper.el.ELContextImpl;
+
+public class TestBeanELResolver {
+
+    @Test
+    public void testBug53421() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        ELContext context = new ELContextImpl();
+
+        Bean bean = new Bean();
+
+        ValueExpression varBean =
+            factory.createValueExpression(bean, Bean.class);
+        context.getVariableMapper().setVariable("bean", varBean);
+
+
+        ValueExpression ve = factory.createValueExpression(
+                context, "${bean.valueA}", String.class);
+        Exception e = null;
+        try {
+            ve.getValue(context);
+        } catch (PropertyNotFoundException pnfe) {
+            e = pnfe;
+        }
+        Assert.assertTrue("Wrong exception type",
+                e instanceof PropertyNotFoundException);
+        String type = Bean.class.getName();
+        @SuppressWarnings("null") // Assert above prevents msg being null
+        String msg = e.getMessage();
+        Assert.assertTrue("No reference to type [" + type +
+                "] where property cannot be found in [" + msg + "]",
+                msg.contains(type));
+    }
+
+    private static class Bean {
+
+        @SuppressWarnings("unused")
+        public void setValueA(String valueA) {
+            // NOOP
+        }
+    }
+}

Propchange: tomcat/trunk/test/javax/el/TestBeanELResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native



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


Mime
View raw message