You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/05/07 20:45:36 UTC

[1/5] [lang] add testConstructorWithNullObject case in ReflectionToStringBuilderTest.java

Repository: commons-lang
Updated Branches:
  refs/heads/master 0e96d84e2 -> dee94449e


add testConstructorWithNullObject case in ReflectionToStringBuilderTest.java


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/474a8378
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/474a8378
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/474a8378

Branch: refs/heads/master
Commit: 474a837858a8e7a98316f97e9ed387d0161015f2
Parents: d6dd2b4
Author: Jack <79...@qq.com>
Authored: Wed May 6 11:10:11 2015 +0800
Committer: Jack <79...@qq.com>
Committed: Wed May 6 11:10:11 2015 +0800

----------------------------------------------------------------------
 .../lang3/builder/ReflectionToStringBuilderTest.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/474a8378/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java
new file mode 100644
index 0000000..2410216
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java
@@ -0,0 +1,12 @@
+package org.apache.commons.lang3.builder;
+
+import org.junit.Test;
+
+public class ReflectionToStringBuilderTest {
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testConstructorWithNullObject() {
+        new ReflectionToStringBuilder(null, ToStringStyle.DEFAULT_STYLE, new StringBuffer());
+    }
+
+}


[2/5] [lang] add checkNotNull method in ReflectionToStringBuilder.java to fix #LANG-1132

Posted by br...@apache.org.
add checkNotNull method in ReflectionToStringBuilder.java to fix #LANG-1132


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/39380da8
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/39380da8
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/39380da8

Branch: refs/heads/master
Commit: 39380da86acc717f419da48f070f8cf7d9f9ec94
Parents: 474a837
Author: Jack <79...@qq.com>
Authored: Wed May 6 11:43:03 2015 +0800
Committer: Jack <79...@qq.com>
Committed: Wed May 6 11:43:03 2015 +0800

----------------------------------------------------------------------
 .../lang3/builder/ReflectionToStringBuilder.java     | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/39380da8/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
index d172b1e..6c2199b 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -362,6 +362,13 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     public static String toStringExclude(final Object object, final String... excludeFieldNames) {
         return new ReflectionToStringBuilder(object).setExcludeFieldNames(excludeFieldNames).toString();
     }
+    
+    private static Object checkNotNull(final Object obj) {
+        if (obj == null) {
+            throw new IllegalArgumentException("The Object passed in should not be null.");
+        }
+        return obj;
+    }
 
     /**
      * Whether or not to append static fields.
@@ -400,7 +407,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *             if the Object passed in is <code>null</code>
      */
     public ReflectionToStringBuilder(final Object object) {
-        super(object);
+        super(checkNotNull(object));
     }
 
     /**
@@ -420,7 +427,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *             if the Object passed in is <code>null</code>
      */
     public ReflectionToStringBuilder(final Object object, final ToStringStyle style) {
-        super(object, style);
+        super(checkNotNull(object), style);
     }
 
     /**
@@ -446,7 +453,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *             if the Object passed in is <code>null</code>
      */
     public ReflectionToStringBuilder(final Object object, final ToStringStyle style, final StringBuffer buffer) {
-        super(object, style, buffer);
+        super(checkNotNull(object), style, buffer);
     }
 
     /**
@@ -471,7 +478,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     public <T> ReflectionToStringBuilder(
             final T object, final ToStringStyle style, final StringBuffer buffer,
             final Class<? super T> reflectUpToClass, final boolean outputTransients, final boolean outputStatics) {
-        super(object, style, buffer);
+        super(checkNotNull(object), style, buffer);
         this.setUpToClass(reflectUpToClass);
         this.setAppendTransients(outputTransients);
         this.setAppendStatics(outputStatics);


[4/5] [lang] Add LANG-1132 to changes.xml

Posted by br...@apache.org.
Add LANG-1132 to changes.xml


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/d282015e
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/d282015e
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/d282015e

Branch: refs/heads/master
Commit: d282015e73ffce5b6d08a5244e890c7ea1a73400
Parents: 0e26620
Author: Benedikt Ritter <br...@apache.org>
Authored: Thu May 7 20:41:02 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Thu May 7 20:41:02 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d282015e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ab6245e..9692e35 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.5" date="tba" description="tba">
+    <action issue="LANG-1132" type="add" dev="britter" due-to="Jack Tan">ReflectionToStringBuilder doesn't throw IllegalArgumentException when the constructor's object param is null</action>
     <action issue="LANG-701" type="add" dev="britter" due-to="James Sawle">StringUtils join with var args</action>
     <action issue="LANG-1130" type="fix" dev="britter">Fix critical issues reported by SonarQube</action>
     <action issue="LANG-1131" type="fix" dev="britter">StrBuilder.equals(StrBuilder) doesn't check for null inputs</action>


[5/5] [lang] Merge branch 'LANG-1132'

Posted by br...@apache.org.
Merge branch 'LANG-1132'

LANG-1132: ReflectionToStringBuilder doesn't throw IllegalArgumentException when
the constructor's object param is null. Thanks to Jack Tan.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/dee94449
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/dee94449
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/dee94449

Branch: refs/heads/master
Commit: dee94449e6abb1b999213a0e8efbe937bcff693b
Parents: 0e96d84 d282015
Author: Benedikt Ritter <br...@apache.org>
Authored: Thu May 7 20:44:47 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Thu May 7 20:44:47 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                              |  1 +
 .../lang3/builder/ReflectionToStringBuilder.java     | 15 +++++++++++----
 .../lang3/builder/ReflectionToStringBuilderTest.java | 12 ++++++++++++
 .../commons/lang3/builder/ToStringBuilderTest.java   |  2 +-
 4 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/dee94449/src/changes/changes.xml
----------------------------------------------------------------------
diff --cc src/changes/changes.xml
index 62d05b1,9692e35..6268c85
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@@ -22,7 -22,7 +22,8 @@@
    <body>
  
    <release version="3.5" date="tba" description="tba">
+     <action issue="LANG-1132" type="add" dev="britter" due-to="Jack Tan">ReflectionToStringBuilder doesn't throw IllegalArgumentException when the constructor's object param is null</action>
 +    <action issue="LANG-1122" type="fix" dev="britter" due-to="Adrian Ber">Inconsistent behavior of swap for malformed inputs</action>
      <action issue="LANG-701" type="add" dev="britter" due-to="James Sawle">StringUtils join with var args</action>
      <action issue="LANG-1130" type="fix" dev="britter">Fix critical issues reported by SonarQube</action>
      <action issue="LANG-1131" type="fix" dev="britter">StrBuilder.equals(StrBuilder) doesn't check for null inputs</action>


[3/5] [lang] add expected=IllegalArgumentException.class to ToStringBuilderTest.testReflectionNull

Posted by br...@apache.org.
add expected=IllegalArgumentException.class to ToStringBuilderTest.testReflectionNull


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/0e266204
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/0e266204
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/0e266204

Branch: refs/heads/master
Commit: 0e266204f535aa48f74d4f2480b2268c13e26b22
Parents: 39380da
Author: Jack <79...@qq.com>
Authored: Wed May 6 13:34:37 2015 +0800
Committer: Jack <79...@qq.com>
Committed: Wed May 6 13:34:37 2015 +0800

----------------------------------------------------------------------
 .../java/org/apache/commons/lang3/builder/ToStringBuilderTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/0e266204/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
index 3101071..c55fe2f 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
@@ -1041,7 +1041,7 @@ public class ToStringBuilderTest {
         static final int staticInt2 = 67890;
     }
 
-    @Test
+    @Test(expected=IllegalArgumentException.class)
     public void testReflectionNull() {
         assertEquals("<null>", ReflectionToStringBuilder.toString(null));
     }