commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1452036 - in /commons/proper/beanutils/trunk: pom.xml src/changes/changes.xml src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
Date Sun, 03 Mar 2013 13:14:38 GMT
Author: britter
Date: Sun Mar  3 13:14:38 2013
New Revision: 1452036

URL: http://svn.apache.org/r1452036
Log:
[BEANUTILS-411] - BeanUtilsBean.setProperty throws IllegalArgumentException if getter of nested
property returns null. Thanks to Marcus Zander

Added:
    commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
  (with props)
Modified:
    commons/proper/beanutils/trunk/pom.xml
    commons/proper/beanutils/trunk/src/changes/changes.xml
    commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java

Modified: commons/proper/beanutils/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/pom.xml?rev=1452036&r1=1452035&r2=1452036&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/pom.xml (original)
+++ commons/proper/beanutils/trunk/pom.xml Sun Mar  3 13:14:38 2013
@@ -144,6 +144,10 @@
       <name>Alex Crown</name>
       <email></email>
     </contributor>    
+    <contributor>
+      <name>Marcus Zander</name>
+      <email>marcus.z@gmx.de</email>
+    </contributor>    
   </contributors>
 
   <dependencies>

Modified: commons/proper/beanutils/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/changes/changes.xml?rev=1452036&r1=1452035&r2=1452036&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/changes/changes.xml (original)
+++ commons/proper/beanutils/trunk/src/changes/changes.xml Sun Mar  3 13:14:38 2013
@@ -40,6 +40,9 @@ The <action> type attribute can be add,u
   <body>
 
     <release version="1.8.4" date="in SVN" description="Bug fix for 1.8.3">
+      <action dev="britter" type="fix" issue="BEANUTILS-411" due-to="Marcus Zander">
+         BeanUtilsBean.setProperty throws IllegalArgumentException if getter of nested property
returns null
+      </action>
       <action dev="britter" type="update" issue="BEANUTILS-429" >
          Delete trailing white spaces and white spaces on empty lines from all files
       </action>

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java?rev=1452036&r1=1452035&r2=1452036&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
(original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/BeanUtilsBean.java
Sun Mar  3 13:14:38 2013
@@ -901,6 +901,9 @@ public class BeanUtilsBean {
         while (resolver.hasNested(name)) {
             try {
                 target = getPropertyUtils().getProperty(target, resolver.next(name));
+                if (target == null) { // the value of a nested property is null
+                    return;
+                }
                 name = resolver.remove(name);
             } catch (NoSuchMethodException e) {
                 return; // Skip this property setter

Added: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java?rev=1452036&view=auto
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
(added)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
Sun Mar  3 13:14:38 2013
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.commons.beanutils.bugs;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.beanutils.BeanUtilsBean;
+
+/**
+ * BeanUtilsBean.setProperty throws IllegalArgumentException if getter of nested
+ * property returns null
+ *
+ * <p />
+ * See https://issues.apache.org/jira/browse/BEANUTILS-411
+ * <p />
+ *
+ * @version $Revision$ $Date$
+ */
+public class Jira411TestCase extends TestCase {
+
+    private BeanUtilsBean instance;
+    private DummyBean testBean;
+
+    protected void setUp() throws Exception {
+        instance = new BeanUtilsBean();
+        testBean = new DummyBean();
+    }
+
+    public void testSetProperty() throws Exception {
+        instance.setProperty(testBean, "imgLink.x", "1");
+    }
+
+    public class DummyBean {
+
+        private String imgLink = null;
+
+        public String getImgLink() {
+            return imgLink;
+        }
+
+        public void setImgLink(String imgLink) {
+            this.imgLink = imgLink;
+        }
+    }
+}

Propchange: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira411TestCase.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Mar  3 13:14:38 2013
@@ -0,0 +1,2 @@
+Revision
+Date



Mime
View raw message