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 2017/05/17 15:03:45 UTC

[01/50] [lang] Merge remote-tracking branch 'APACHE/master' [Forced Update!]

Repository: commons-lang
Updated Branches:
  refs/heads/release 1ec464dac -> 3a64cf6af (forced update)


Merge remote-tracking branch 'APACHE/master'


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

Branch: refs/heads/release
Commit: 40b8ecd3faa8df655ee8b4141ff309553eccfc88
Parents: 3072c65 bf80b9e
Author: MarkDacek <ma...@richmond.edu>
Authored: Fri Mar 17 17:43:15 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Fri Mar 17 17:43:15 2017 -0400

----------------------------------------------------------------------
 .travis.yml                                     |   5 +-
 checkstyle.xml                                  |   5 +-
 pom.xml                                         |  16 +-
 src/changes/changes.xml                         |   4 +-
 .../org/apache/commons/lang3/ArrayUtils.java    |   5 +-
 .../apache/commons/lang3/CharSequenceUtils.java |  97 ++++++-
 .../org/apache/commons/lang3/StringUtils.java   | 264 ++++++++++++-------
 .../commons/lang3/concurrent/Computable.java    |   2 +-
 .../concurrent/annotation/package-info.java     |  22 ++
 .../commons/lang3/exception/ExceptionUtils.java |   1 -
 .../apache/commons/lang3/time/DateUtils.java    |   6 +-
 .../apache/commons/lang3/ClassUtilsTest.java    |  86 +++---
 .../lang3/StringUtilsEmptyBlankTest.java        |  55 ++--
 .../lang3/StringUtilsEqualsIndexOfTest.java     |  49 ++++
 .../exception/AbstractExceptionContextTest.java |   4 +-
 15 files changed, 425 insertions(+), 196 deletions(-)
----------------------------------------------------------------------



[24/50] [lang] use Assert#assertFalse instead of Assert#assertTrue with a negated condition

Posted by br...@apache.org.
use Assert#assertFalse instead of Assert#assertTrue with a negated condition


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

Branch: refs/heads/release
Commit: a060733e63a9cc476342ca190d04ad027a241d33
Parents: d5be24a
Author: pascalschumacher <pa...@gmx.net>
Authored: Sat Apr 22 22:25:52 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sat Apr 22 22:25:52 2017 +0200

----------------------------------------------------------------------
 .../org/apache/commons/lang3/BitFieldTest.java  |  12 +-
 .../lang3/builder/EqualsBuilderTest.java        | 170 +++++++++----------
 .../exception/AbstractExceptionContextTest.java |   7 +-
 .../lang3/exception/ExceptionUtilsTest.java     |   4 +-
 4 files changed, 97 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a060733e/src/test/java/org/apache/commons/lang3/BitFieldTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/BitFieldTest.java b/src/test/java/org/apache/commons/lang3/BitFieldTest.java
index 0c80f5a..7d4ae9a 100644
--- a/src/test/java/org/apache/commons/lang3/BitFieldTest.java
+++ b/src/test/java/org/apache/commons/lang3/BitFieldTest.java
@@ -88,15 +88,15 @@ public class BitFieldTest  {
      */
     @Test
     public void testIsSet() {
-        assertTrue(!bf_multi.isSet(0));
-        assertTrue(!bf_zero.isSet(0));
+        assertFalse(bf_multi.isSet(0));
+        assertFalse(bf_zero.isSet(0));
         for (int j = 0x80; j <= 0x3F80; j += 0x80) {
             assertTrue(bf_multi.isSet(j));
         }
         for (int j = 0x80; j <= 0x3F80; j += 0x80) {
-            assertTrue(!bf_zero.isSet(j));
+            assertFalse(bf_zero.isSet(j));
         }
-        assertTrue(!bf_single.isSet(0));
+        assertFalse(bf_single.isSet(0));
         assertTrue(bf_single.isSet(0x4000));
     }
 
@@ -106,11 +106,11 @@ public class BitFieldTest  {
     @Test
     public void testIsAllSet() {
         for (int j = 0; j < 0x3F80; j += 0x80) {
-            assertTrue(!bf_multi.isAllSet(j));
+            assertFalse(bf_multi.isAllSet(j));
             assertTrue(bf_zero.isAllSet(j));
         }
         assertTrue(bf_multi.isAllSet(0x3F80));
-        assertTrue(!bf_single.isAllSet(0));
+        assertFalse(bf_single.isAllSet(0));
         assertTrue(bf_single.isAllSet(0x4000));
     }
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a060733e/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
index bb7ca66..b5cfdfa 100644
--- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java
@@ -213,14 +213,14 @@ public class EqualsBuilderTest {
         final TestObject o1 = new TestObject(4);
         final TestObject o2 = new TestObject(5);
         assertTrue(EqualsBuilder.reflectionEquals(o1, o1));
-        assertTrue(!EqualsBuilder.reflectionEquals(o1, o2));
+        assertFalse(EqualsBuilder.reflectionEquals(o1, o2));
         o2.setA(4);
         assertTrue(EqualsBuilder.reflectionEquals(o1, o2));
 
-        assertTrue(!EqualsBuilder.reflectionEquals(o1, this));
+        assertFalse(EqualsBuilder.reflectionEquals(o1, this));
 
-        assertTrue(!EqualsBuilder.reflectionEquals(o1, null));
-        assertTrue(!EqualsBuilder.reflectionEquals(null, o2));
+        assertFalse(EqualsBuilder.reflectionEquals(o1, null));
+        assertFalse(EqualsBuilder.reflectionEquals(null, o2));
         assertTrue(EqualsBuilder.reflectionEquals(null, null));
     }
     
@@ -231,9 +231,9 @@ public class EqualsBuilderTest {
         // Transients
         assertTrue(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), true));
         assertTrue(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), false));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 0, 0, 4), new TestTTLeafObject(1, 2, 3, 4), true));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 0), true));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestTTLeafObject(0, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), true));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 0, 0, 4), new TestTTLeafObject(1, 2, 3, 4), true));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestTTLeafObject(1, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 0), true));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestTTLeafObject(0, 2, 3, 4), new TestTTLeafObject(1, 2, 3, 4), true));
     }
 
     private void testReflectionHierarchyEquals(final boolean testTransients) {
@@ -259,11 +259,11 @@ public class EqualsBuilderTest {
         assertTrue(EqualsBuilder.reflectionEquals(ttlo, ttlo, testTransients));
         assertTrue(EqualsBuilder.reflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 10), testTransients));
         // same super values, diff sub values
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 11), testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestSubObject(1, 11), new TestSubObject(1, 10), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 11), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestSubObject(1, 11), new TestSubObject(1, 10), testTransients));
         // diff super values, same sub values
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestSubObject(0, 10), new TestSubObject(1, 10), testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestSubObject(1, 10), new TestSubObject(0, 10), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestSubObject(0, 10), new TestSubObject(1, 10), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestSubObject(1, 10), new TestSubObject(0, 10), testTransients));
 
         // mix super and sub types: equals
         assertTrue(EqualsBuilder.reflectionEquals(to1, teso, testTransients));
@@ -279,17 +279,17 @@ public class EqualsBuilderTest {
         assertTrue(EqualsBuilder.reflectionEquals(tttso, ttso, false)); // Force testTransients = false for this assert
 
         // mix super and sub types: NOT equals
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestObject(0), new TestEmptySubObject(1), testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestEmptySubObject(1), new TestObject(0), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestObject(0), new TestEmptySubObject(1), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestEmptySubObject(1), new TestObject(0), testTransients));
 
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestObject(0), new TestTSubObject(1, 1), testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestTSubObject(1, 1), new TestObject(0), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestObject(0), new TestTSubObject(1, 1), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestTSubObject(1, 1), new TestObject(0), testTransients));
 
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestObject(1), new TestSubObject(0, 10), testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(new TestSubObject(0, 10), new TestObject(1), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestObject(1), new TestSubObject(0, 10), testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(new TestSubObject(0, 10), new TestObject(1), testTransients));
 
-        assertTrue(!EqualsBuilder.reflectionEquals(to1, ttlo));
-        assertTrue(!EqualsBuilder.reflectionEquals(tso1, this));
+        assertFalse(EqualsBuilder.reflectionEquals(to1, ttlo));
+        assertFalse(EqualsBuilder.reflectionEquals(tso1, this));
     }
 
     /**
@@ -340,14 +340,14 @@ public class EqualsBuilderTest {
         if (oToChange instanceof TestSubObject) {
             ((TestSubObject) oToChange).setB(((TestSubObject) to).getB() + 1);
         }
-        assertTrue(!EqualsBuilder.reflectionEquals(oToChange, to, testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(oToChange, to, testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(oToChange, to, testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(oToChange, to, testTransients));
 
         // non-null reference test
-        assertTrue(!EqualsBuilder.reflectionEquals(to, null, testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(to2, null, testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(null, to, testTransients));
-        assertTrue(!EqualsBuilder.reflectionEquals(null, to2, testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(to, null, testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(to2, null, testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(null, to, testTransients));
+        assertFalse(EqualsBuilder.reflectionEquals(null, to2, testTransients));
         assertTrue(EqualsBuilder.reflectionEquals(null, null, testTransients));
     }
 
@@ -366,14 +366,14 @@ public class EqualsBuilderTest {
         final TestObject o1 = new TestObject(4);
         final TestObject o2 = new TestObject(5);
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
         o2.setA(4);
         assertTrue(new EqualsBuilder().append(o1, o2).isEquals());
 
-        assertTrue(!new EqualsBuilder().append(o1, this).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, this).isEquals());
         
-        assertTrue(!new EqualsBuilder().append(o1, null).isEquals());
-        assertTrue(!new EqualsBuilder().append(null, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, null).isEquals());
+        assertFalse(new EqualsBuilder().append(null, o2).isEquals());
         assertTrue(new EqualsBuilder().append((Object) null, null).isEquals());
     }
     
@@ -454,7 +454,7 @@ public class EqualsBuilderTest {
         final long o1 = 1L;
         final long o2 = 2L;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
     }
 
     @Test
@@ -462,7 +462,7 @@ public class EqualsBuilderTest {
         final int o1 = 1;
         final int o2 = 2;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
     }
 
     @Test
@@ -470,7 +470,7 @@ public class EqualsBuilderTest {
         final short o1 = 1;
         final short o2 = 2;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
     }
 
     @Test
@@ -478,7 +478,7 @@ public class EqualsBuilderTest {
         final char o1 = 1;
         final char o2 = 2;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
     }
 
     @Test
@@ -486,7 +486,7 @@ public class EqualsBuilderTest {
         final byte o1 = 1;
         final byte o2 = 2;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
     }
 
     @Test
@@ -494,8 +494,8 @@ public class EqualsBuilderTest {
         final double o1 = 1;
         final double o2 = 2;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, Double.NaN).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, Double.NaN).isEquals());
         assertTrue(new EqualsBuilder().append(Double.NaN, Double.NaN).isEquals());
         assertTrue(new EqualsBuilder().append(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY).isEquals());
     }
@@ -505,8 +505,8 @@ public class EqualsBuilderTest {
         final float o1 = 1;
         final float o2 = 2;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, Float.NaN).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, Float.NaN).isEquals());
         assertTrue(new EqualsBuilder().append(Float.NaN, Float.NaN).isEquals());
         assertTrue(new EqualsBuilder().append(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY).isEquals());
     }
@@ -536,7 +536,7 @@ public class EqualsBuilderTest {
         final boolean o1 = true;
         final boolean o2 = false;
         assertTrue(new EqualsBuilder().append(o1, o1).isEquals());
-        assertTrue(!new EqualsBuilder().append(o1, o2).isEquals());
+        assertFalse(new EqualsBuilder().append(o1, o2).isEquals());
     }
 
     @Test
@@ -554,16 +554,16 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj2, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1].setA(6);
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1].setA(5);
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[2] = obj1[1];
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[2] = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
                        
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -579,10 +579,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -598,10 +598,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -617,10 +617,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -636,10 +636,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -655,10 +655,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -674,10 +674,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -693,10 +693,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -712,10 +712,10 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1[1] = true;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
 
         obj2 = null;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
         obj1 = null;
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
@@ -733,7 +733,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -749,7 +749,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -765,7 +765,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -781,7 +781,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -797,7 +797,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -813,7 +813,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -829,7 +829,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -845,7 +845,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = false;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
         
         // compare 1 dim to 2.
         final boolean[] array3 = new boolean[]{true, true};
@@ -870,7 +870,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         array1[1][1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -888,7 +888,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
         assertTrue(new EqualsBuilder().append(array1, array2).isEquals());
         ((long[]) array1[1])[1] = 0;
-        assertTrue(!new EqualsBuilder().append(array1, array2).isEquals());
+        assertFalse(new EqualsBuilder().append(array1, array2).isEquals());
     }
 
     @Test
@@ -906,7 +906,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1].setA(6);
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -924,7 +924,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -942,7 +942,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -960,7 +960,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -978,7 +978,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -996,7 +996,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -1014,7 +1014,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -1032,7 +1032,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = 7;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
 
     @Test
@@ -1050,7 +1050,7 @@ public class EqualsBuilderTest {
         assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals());
         assertTrue(new EqualsBuilder().append(obj1, array2).isEquals());
         array1[1] = true;
-        assertTrue(!new EqualsBuilder().append(obj1, obj2).isEquals());
+        assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals());
     }
     
     public static class TestACanEqualB {
@@ -1160,16 +1160,16 @@ public class EqualsBuilderTest {
         final TestObjectWithMultipleFields x2 = new TestObjectWithMultipleFields(1, 3, 4);
 
         // not equal when including all fields
-        assertTrue(!EqualsBuilder.reflectionEquals(x1, x2));
+        assertFalse(EqualsBuilder.reflectionEquals(x1, x2));
 
         // doesn't barf on null, empty array, or non-existent field, but still tests as not equal
-        assertTrue(!EqualsBuilder.reflectionEquals(x1, x2, (String[]) null));
-        assertTrue(!EqualsBuilder.reflectionEquals(x1, x2, new String[] {}));
-        assertTrue(!EqualsBuilder.reflectionEquals(x1, x2, new String[] {"xxx"}));
+        assertFalse(EqualsBuilder.reflectionEquals(x1, x2, (String[]) null));
+        assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {}));
+        assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"xxx"}));
 
         // not equal if only one of the differing fields excluded
-        assertTrue(!EqualsBuilder.reflectionEquals(x1, x2, new String[] {"two"}));
-        assertTrue(!EqualsBuilder.reflectionEquals(x1, x2, new String[] {"three"}));
+        assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"two"}));
+        assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"three"}));
 
         // equal if both differing fields excluded
         assertTrue(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"two", "three"}));
@@ -1253,7 +1253,7 @@ public class EqualsBuilderTest {
         final Object[] o2 = new Object[] { two };
         final Object[] o3 = new Object[] { one };
 
-        assertTrue(!EqualsBuilder.reflectionEquals(o1, o2));
+        assertFalse(EqualsBuilder.reflectionEquals(o1, o2));
         assertTrue(EqualsBuilder.reflectionEquals(o1, o1));
         assertTrue(EqualsBuilder.reflectionEquals(o1, o3));
         
@@ -1261,7 +1261,7 @@ public class EqualsBuilderTest {
         final double[] d2 = { 2, 3 };
         final double[] d3 = { 0, 1 };
         
-        assertTrue(!EqualsBuilder.reflectionEquals(d1, d2));
+        assertFalse(EqualsBuilder.reflectionEquals(d1, d2));
         assertTrue(EqualsBuilder.reflectionEquals(d1, d1));
         assertTrue(EqualsBuilder.reflectionEquals(d1, d3));
     }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a060733e/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
index 85b5243..ce94122 100644
--- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
@@ -20,6 +20,7 @@ import org.junit.Test;
 import org.junit.Before;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.Serializable;
@@ -85,7 +86,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
         assertTrue(exceptionContext.getContextLabels().contains("test2"));
 
         final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
-        assertTrue(!contextMessage.contains(TEST_MESSAGE));
+        assertFalse(contextMessage.contains(TEST_MESSAGE));
     }
 
     @Test
@@ -105,7 +106,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
         assertEquals(6, exceptionContext.getContextLabels().size());
 
         assertTrue(exceptionContext.getContextLabels().contains("test Poorly written obj"));
-        assertTrue(!exceptionContext.getContextLabels().contains("crap"));
+        assertFalse(exceptionContext.getContextLabels().contains("crap"));
 
         exceptionContext.setContextValue("test Poorly written obj", "replacement");
 
@@ -118,7 +119,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
         assertEquals(6, exceptionContext.getContextLabels().size());
 
         final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
-        assertTrue(!contextMessage.contains(TEST_MESSAGE));
+        assertFalse(contextMessage.contains(TEST_MESSAGE));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a060733e/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index 7a4cf9d..af8b847 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -393,7 +393,7 @@ public class ExceptionUtilsTest {
         out = new ByteArrayOutputStream(1024);
         ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintStream(out));
         stackTrace = out.toString();
-        assertTrue(!stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
+        assertFalse(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
     }
 
     @Test
@@ -419,7 +419,7 @@ public class ExceptionUtilsTest {
         writer = new StringWriter(1024);
         ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintWriter(writer));
         stackTrace = writer.toString();
-        assertTrue(!stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
+        assertFalse(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
     }
 
     //-----------------------------------------------------------------------


[18/50] [lang] LANG-1167: attributing work to Mark Dacek

Posted by br...@apache.org.
LANG-1167: attributing work to Mark Dacek


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

Branch: refs/heads/release
Commit: 0446364ffa1c476dfdd95df5be94444f847973f3
Parents: 8147cc5
Author: Rob Tompkins <ch...@gmail.com>
Authored: Thu Apr 20 11:23:42 2017 -0400
Committer: Rob Tompkins <ch...@gmail.com>
Committed: Thu Apr 20 11:23:42 2017 -0400

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


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/0446364f/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f16bb26..e50441b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.6" date="2017-MM-DD" description="TBD">
+    <action issue="LANG-1167" type="add" dev="chtompki" due-to="Mark Dacek">Add null filter to ReflectionToStringBuilder</action>
     <action issue="LANG-1312" type="fix" dev="britter">LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code followed by variant</action>
     <action issue="LANG-1300" type="fix" dev="chtompki" due-to="Mark Dacek">Clarify or improve behaviour of int-based indexOf methods in StringUtils</action>
     <action issue="LANG-1299" type="add" dev="djones">Add method for converting string to an array of code points</action>


[31/50] [lang] Increase test coverage of ToStringBuilder class to 100%

Posted by br...@apache.org.
Increase test coverage of ToStringBuilder class to 100%


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

Branch: refs/heads/release
Commit: ece2f255eed8ad9eff6e236152de65e804c6adb5
Parents: 331d2f2
Author: Basha <ar...@paypalcorp.com>
Authored: Sat Apr 29 18:11:13 2017 +0530
Committer: Basha <ar...@paypalcorp.com>
Committed: Sat Apr 29 19:22:59 2017 +0530

----------------------------------------------------------------------
 .../lang3/builder/ToStringBuilderTest.java      | 225 +++++++++++++++++++
 1 file changed, 225 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ece2f255/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 eba610a..b218329 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
@@ -615,6 +615,231 @@ public class ToStringBuilderTest {
     }
 
     @Test
+    public void testAppendAsObjectToString() {
+        String objectToAppend1 = "";
+        Boolean objectToAppend2 = Boolean.TRUE;
+        Object objectToAppend3 = new Object();
+
+        assertEquals(baseStr + "[" + toBaseString(objectToAppend1) + "]",
+                new ToStringBuilder(base).appendAsObjectToString(objectToAppend1).toString());
+        assertEquals(baseStr + "[" + toBaseString(objectToAppend2) + "]",
+                new ToStringBuilder(base).appendAsObjectToString(objectToAppend2).toString());
+        assertEquals(baseStr + "[" + toBaseString(objectToAppend3) + "]",
+                new ToStringBuilder(base).appendAsObjectToString(objectToAppend3).toString());
+    }
+
+    @Test
+    public void testAppendBooleanArrayWithFieldName() {
+        boolean[] array = new boolean[] { true, false, false };
+        assertEquals(baseStr + "[flags={true,false,false}]",
+                new ToStringBuilder(base).append("flags", array).toString());
+        assertEquals(baseStr + "[flags=<null>]",
+                new ToStringBuilder(base).append("flags", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{true,false,false}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendBooleanArrayWithFieldNameAndFullDetatil() {
+        boolean[] array = new boolean[] { true, false, false };
+        assertEquals(baseStr + "[flags={true,false,false}]",
+                new ToStringBuilder(base).append("flags", array, true).toString());
+        assertEquals(baseStr + "[length=<size=3>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[flags=<null>]",
+                new ToStringBuilder(base).append("flags", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=3>]", new ToStringBuilder(base).append(null, array, false).toString());
+     }
+
+    @Test
+    public void testAppendCharArrayWithFieldName() {
+        char[] array = new char[] { 'A', '2', '_', 'D' };
+        assertEquals(baseStr + "[chars={A,2,_,D}]", new ToStringBuilder(base).append("chars", array).toString());
+        assertEquals(baseStr + "[letters={A,2,_,D}]", new ToStringBuilder(base).append("letters", array).toString());
+        assertEquals(baseStr + "[flags=<null>]",
+                new ToStringBuilder(base).append("flags", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{A,2,_,D}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendCharArrayWithFieldNameAndFullDetatil() {
+        char[] array = new char[] { 'A', '2', '_', 'D' };
+        assertEquals(baseStr + "[chars={A,2,_,D}]", new ToStringBuilder(base).append("chars", array, true).toString());
+        assertEquals(baseStr + "[letters=<size=4>]",
+                new ToStringBuilder(base).append("letters", array, false).toString());
+        assertEquals(baseStr + "[flags=<null>]",
+                new ToStringBuilder(base).append("flags", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendDoubleArrayWithFieldName() {
+        double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
+        assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
+                new ToStringBuilder(base).append("values", array).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{1.0,2.9876,-3.00001,4.3}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendDoubleArrayWithFieldNameAndFullDetatil() {
+        double[] array = new double[] { 1.0, 2.9876, -3.00001, 4.3 };
+        assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
+                new ToStringBuilder(base).append("values", array, true).toString());
+        assertEquals(baseStr + "[length=<size=4>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendObjectArrayWithFieldName() {
+        Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
+        assertEquals(baseStr + "[values={<null>,5,{3,6}}]",
+                new ToStringBuilder(base).append("values", array).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{<null>,5,{3,6}}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendObjectArrayWithFieldNameAndFullDetatil() {
+       Object[] array = new Object[] { null, base, new int[] { 3, 6 } };
+       assertEquals(baseStr + "[values={<null>,5,{3,6}}]",
+               new ToStringBuilder(base).append("values", array, true).toString());
+       assertEquals(baseStr + "[length=<size=3>]",
+               new ToStringBuilder(base).append("length", array, false).toString());
+       assertEquals(baseStr + "[values=<null>]",
+               new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+       assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+       assertEquals(baseStr + "[<size=3>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendLongArrayWithFieldName() {
+       long[] array = new long[] { 1, 2, -3, 4 };
+       assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
+       assertEquals(baseStr + "[values=<null>]",
+               new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+       assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+       assertEquals(baseStr + "[{1,2,-3,4}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendLongArrayWithFieldNameAndFullDetatil() {
+        long[] array = new long[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]",
+                new ToStringBuilder(base).append("values", array, true).toString());
+        assertEquals(baseStr + "[length=<size=4>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendIntArrayWithFieldName() {
+        int[] array = new int[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{1,2,-3,4}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendIntArrayWithFieldNameAndFullDetatil() {
+        int[] array = new int[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]",
+                new ToStringBuilder(base).append("values", array, true).toString());
+        assertEquals(baseStr + "[length=<size=4>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendShortArrayWithFieldName() {
+        short[] array = new short[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{1,2,-3,4}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendShortArrayWithFieldNameAndFullDetatil() {
+        short[] array = new short[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]",
+                new ToStringBuilder(base).append("values", array, true).toString());
+        assertEquals(baseStr + "[length=<size=4>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendByteArrayWithFieldName() {
+        byte[] array = new byte[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]", new ToStringBuilder(base).append("values", array).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{1,2,-3,4}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendByteArrayWithFieldNameAndFullDetatil() {
+        byte[] array = new byte[] { 1, 2, -3, 4 };
+        assertEquals(baseStr + "[values={1,2,-3,4}]",
+                new ToStringBuilder(base).append("values", array, true).toString());
+        assertEquals(baseStr + "[length=<size=4>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
+    public void testAppendFloatArrayWithFieldName() {
+        float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
+        assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
+                new ToStringBuilder(base).append("values", array).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null).toString());
+        assertEquals(baseStr + "[{1.0,2.9876,-3.00001,4.3}]", new ToStringBuilder(base).append(null, array).toString());
+    }
+
+    @Test
+    public void testAppendFloatArrayWithFieldNameAndFullDetatil() {
+        float[] array = new float[] { 1.0f, 2.9876f, -3.00001f, 4.3f };
+        assertEquals(baseStr + "[values={1.0,2.9876,-3.00001,4.3}]",
+                new ToStringBuilder(base).append("values", array, true).toString());
+        assertEquals(baseStr + "[length=<size=4>]",
+                new ToStringBuilder(base).append("length", array, false).toString());
+        assertEquals(baseStr + "[values=<null>]",
+                new ToStringBuilder(base).append("values", (boolean[]) null, true).toString());
+        assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
+        assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
+    }
+
+    @Test
     public void testObject() {
         final Integer i3 = Integer.valueOf(3);
         final Integer i4 = Integer.valueOf(4);


[30/50] [lang] HashSetvBitSetTest: use diamond operator (closes #264)

Posted by br...@apache.org.
HashSetvBitSetTest: use diamond operator (closes #264)

Use Java 7's diamond operator to make the code a tad more elegant, as
done in the rest of the codebase.


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

Branch: refs/heads/release
Commit: c8e648b92cc133a604b5e1f4da1ced943788e64b
Parents: d61090a
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 29 10:37:40 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sat Apr 29 10:48:41 2017 +0200

----------------------------------------------------------------------
 src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c8e648b9/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
index cafb298..97fe714 100644
--- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
+++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
@@ -39,7 +39,7 @@ public class HashSetvBitSetTest {
 
     @Benchmark
     public int[] testHashSet() {
-        final HashSet<Integer> toRemove = new HashSet<Integer>();
+        final HashSet<Integer> toRemove = new HashSet<>();
         int found = 0;
         for (int i = 0; i < numberOfElementsToCompute; i++) {
             toRemove.add(found++);


[27/50] [lang] LANG-1256: Add JMH maven dependencies.

Posted by br...@apache.org.
LANG-1256: Add JMH maven dependencies.

do not run checksytle on classes generated by JMH

remove unnecessary maven-compiler-plugin configuration from benchmark profile


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

Branch: refs/heads/release
Commit: 331d2f21f96ea6d1197fd8fb0774109a8e9732b5
Parents: e685d84
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Apr 28 18:34:29 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 28 18:34:29 2017 +0200

----------------------------------------------------------------------
 pom.xml | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/331d2f21/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9b22eb3..0f842fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -675,6 +675,10 @@
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
+          <!-- necessary to exclude classes generated by JMH for check -->
+          <testSourceDirectories>
+            <testSourceDirectory>src/test/java</testSourceDirectory>
+          </testSourceDirectories>
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>
@@ -700,6 +704,10 @@
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
+          <!-- necessary to exclude classes generated by JMH for check -->
+          <testSourceDirectories>
+            <testSourceDirectory>src/test/java</testSourceDirectory>
+          </testSourceDirectories>
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>
@@ -872,22 +880,12 @@
         <skipTests>true</skipTests>
         <benchmark>org.apache</benchmark>
       </properties>
-
       <build>
         <plugins>
           <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-compiler-plugin</artifactId>
-            <version>3.1</version>
-            <configuration>
-              <compilerVersion>${maven.compiler.target}</compilerVersion>
-              <source>${maven.compiler.target}</source>
-              <target>${maven.compiler.target}</target>
-            </configuration>
-          </plugin>
-          <plugin>
             <groupId>org.codehaus.mojo</groupId>
             <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>
             <executions>
               <execution>
                 <id>benchmark</id>
@@ -914,6 +912,6 @@
           </plugin>
         </plugins>
       </build>
-    </profile>  </profiles>
-
+    </profile>
+  </profiles>
 </project>


[47/50] [lang] Update download page in preparation for 3.6 release

Posted by br...@apache.org.
Update download page in preparation for 3.6 release


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

Branch: refs/heads/release
Commit: 02f3094eae644ff46f2a7bb8ca2c3d508157ecbc
Parents: 05e18cc
Author: Benedikt Ritter <br...@apache.org>
Authored: Mon Apr 17 13:21:13 2017 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:27:38 2017 -0400

----------------------------------------------------------------------
 pom.xml                         |  2 +-
 src/site/xdoc/download_lang.xml | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/02f3094e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6346074..5aa7856 100644
--- a/pom.xml
+++ b/pom.xml
@@ -577,7 +577,7 @@
     -->
     <commons.componentid>lang3</commons.componentid>
     <!-- Current 3.x release series -->
-    <commons.release.version>3.5</commons.release.version>
+    <commons.release.version>3.6</commons.release.version>
     <commons.release.desc>(Java 6.0+)</commons.release.desc>
     <!-- Previous 2.x release series -->
     <commons.release.2.version>2.6</commons.release.2.version>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/02f3094e/src/site/xdoc/download_lang.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/download_lang.xml b/src/site/xdoc/download_lang.xml
index ca32024..3f752c8 100644
--- a/src/site/xdoc/download_lang.xml
+++ b/src/site/xdoc/download_lang.xml
@@ -111,32 +111,32 @@ limitations under the License.
       </p>
     </subsection>
     </section>
-    <section name="Apache Commons Lang 3.5 (Java 6.0+)">
+    <section name="Apache Commons Lang 3.6 (Java 6.0+)">
       <subsection name="Binaries">
         <table>
           <tr>
-              <td><a href="[preferred]/commons/lang/binaries/commons-lang3-3.5-bin.tar.gz">commons-lang3-3.5-bin.tar.gz</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.5-bin.tar.gz.md5">md5</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.5-bin.tar.gz.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/lang/binaries/commons-lang3-3.6-bin.tar.gz">commons-lang3-3.6-bin.tar.gz</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.6-bin.tar.gz.md5">md5</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.6-bin.tar.gz.asc">pgp</a></td>
           </tr>
           <tr>
-              <td><a href="[preferred]/commons/lang/binaries/commons-lang3-3.5-bin.zip">commons-lang3-3.5-bin.zip</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.5-bin.zip.md5">md5</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.5-bin.zip.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/lang/binaries/commons-lang3-3.6-bin.zip">commons-lang3-3.6-bin.zip</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.6-bin.zip.md5">md5</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/binaries/commons-lang3-3.6-bin.zip.asc">pgp</a></td>
           </tr>
         </table>
       </subsection>
       <subsection name="Source">
         <table>
           <tr>
-              <td><a href="[preferred]/commons/lang/source/commons-lang3-3.5-src.tar.gz">commons-lang3-3.5-src.tar.gz</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.5-src.tar.gz.md5">md5</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.5-src.tar.gz.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/lang/source/commons-lang3-3.6-src.tar.gz">commons-lang3-3.6-src.tar.gz</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.6-src.tar.gz.md5">md5</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.6-src.tar.gz.asc">pgp</a></td>
           </tr>
           <tr>
-              <td><a href="[preferred]/commons/lang/source/commons-lang3-3.5-src.zip">commons-lang3-3.5-src.zip</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.5-src.zip.md5">md5</a></td>
-              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.5-src.zip.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/lang/source/commons-lang3-3.6-src.zip">commons-lang3-3.6-src.zip</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.6-src.zip.md5">md5</a></td>
+              <td><a href="https://www.apache.org/dist/commons/lang/source/commons-lang3-3.6-src.zip.asc">pgp</a></td>
           </tr>
         </table>
       </subsection>


[08/50] [lang] Exclude SF_SWITCH_NO_DEFAULT on FastDatePrinter

Posted by br...@apache.org.
Exclude SF_SWITCH_NO_DEFAULT on FastDatePrinter

FastDatePrinter#appendFullDigits uses a switch case without break
statements.

SF_SWITCH_NO_DEFAULT unfortunately cannot recognize this pattern, and
leave us with no choice but to suppress it.


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

Branch: refs/heads/release
Commit: 8069e1c1ce7ec864c7bab2eae880742fac02376b
Parents: 4d343cc
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:18:53 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8069e1c1/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index edc6ead..23dddbd 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -150,6 +150,14 @@
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
 
+  <!-- Reason: FindBugs cannot correctly recognize default branches in switch statements without break statements.
+   See, e.g., the report at https://sourceforge.net/p/findbugs/bugs/1298 -->
+  <Match>
+    <Class name="org.apache.commons.lang3.time.FastDatePrinter"/>
+    <Method name="appendFullDigits" params="java.lang.Appendable, int, int"/>
+    <Bug pattern="SF_SWITCH_NO_DEFAULT" />
+  </Match>
+
   <!-- Reason: The fallthrough on the swich stateme is intentional -->
   <Match>
     <Class name="org.apache.commons.lang3.time.FastDatePrinter"/>


[20/50] [lang] LANG-1317: Adds MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods (closes #261)

Posted by br...@apache.org.
LANG-1317: Adds MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods (closes #261)


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

Branch: refs/heads/release
Commit: 46007c151e4cd79891eed4d289ff372ba39d5b8c
Parents: 859224f
Author: Yasser Zamani <ya...@live.com>
Authored: Sun Mar 26 01:49:46 2017 +0430
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 21 10:44:41 2017 +0200

----------------------------------------------------------------------
 .../commons/lang3/reflect/MethodUtils.java      | 158 ++++++++++++++++++-
 .../commons/lang3/reflect/MethodUtilsTest.java  | 136 ++++++++++++++++
 .../commons/lang3/reflect/testbed/Foo.java      |   1 +
 .../commons/lang3/reflect/testbed/Parent.java   |   7 +
 .../lang3/reflect/testbed/PublicChild.java      |  16 ++
 5 files changed, 310 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46007c15/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index c6f9795..55b5cb1 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -830,7 +830,7 @@ public class MethodUtils {
     }
 
     /**
-     * Gets all methods of the given class that are annotated with the given annotation.
+     * Gets all class level public methods of the given class that are annotated with the given annotation.
      * @param cls
      *            the {@link Class} to query
      * @param annotationCls
@@ -841,12 +841,11 @@ public class MethodUtils {
      * @since 3.4
      */
     public static Method[] getMethodsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) {
-        final List<Method> annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls);
-        return annotatedMethodsList.toArray(new Method[annotatedMethodsList.size()]);
+        return getMethodsWithAnnotation(cls, annotationCls, false, false);
     }
 
     /**
-     * Gets all methods of the given class that are annotated with the given annotation.
+     * Gets all class level public methods of the given class that are annotated with the given annotation.
      * @param cls
      *            the {@link Class} to query
      * @param annotationCls
@@ -857,16 +856,159 @@ public class MethodUtils {
      * @since 3.4
      */
     public static List<Method> getMethodsListWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) {
+        return getMethodsListWithAnnotation(cls, annotationCls, false, false);
+    }
+
+    /**
+     * Gets all methods of the given class that are annotated with the given annotation.
+     * @param cls
+     *            the {@link Class} to query
+     * @param annotationCls
+     *            the {@link java.lang.annotation.Annotation} that must be present on a method to be matched
+     * @param searchSupers
+     *            determines if also a lookup in the entire inheritance hierarchy of the given class should be performed
+     * @param ignoreAccess
+     *            determines if also non public methods should be considered
+     * @return an array of Methods (possibly empty).
+     * @throws IllegalArgumentException
+     *            if the class or annotation are {@code null}
+     * @since 3.6
+     */
+    public static Method[] getMethodsWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls,
+                                                    boolean searchSupers, boolean ignoreAccess) {
+        final List<Method> annotatedMethodsList = getMethodsListWithAnnotation(cls, annotationCls, searchSupers,
+                ignoreAccess);
+        return annotatedMethodsList.toArray(new Method[annotatedMethodsList.size()]);
+    }
+
+    /**
+     * Gets all methods of the given class that are annotated with the given annotation.
+     * @param cls
+     *            the {@link Class} to query
+     * @param annotationCls
+     *            the {@link Annotation} that must be present on a method to be matched
+     * @param searchSupers
+     *            determines if also a lookup in the entire inheritance hierarchy of the given class should be performed
+     * @param ignoreAccess
+     *            determines if also non public methods should be considered
+     * @return a list of Methods (possibly empty).
+     * @throws IllegalArgumentException
+     *            if the class or annotation are {@code null}
+     * @since 3.6
+     */
+    public static List<Method> getMethodsListWithAnnotation(final Class<?> cls,
+                                                            final Class<? extends Annotation> annotationCls,
+                                                            boolean searchSupers, boolean ignoreAccess) {
+
         Validate.isTrue(cls != null, "The class must not be null");
         Validate.isTrue(annotationCls != null, "The annotation class must not be null");
-        final Method[] allMethods = cls.getMethods();
+        List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
+                : new ArrayList<Class<?>>());
+        classes.add(0, cls);
         final List<Method> annotatedMethods = new ArrayList<>();
-        for (final Method method : allMethods) {
-            if (method.getAnnotation(annotationCls) != null) {
-                annotatedMethods.add(method);
+        for (Class<?> acls : classes) {
+            final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods());
+            for (final Method method : methods) {
+                if (method.getAnnotation(annotationCls) != null) {
+                    annotatedMethods.add(method);
+                }
             }
         }
         return annotatedMethods;
     }
 
+    /**
+     * <p>Gets the annotation object that is present on the given method or any equivalent method in
+     * super classes and interfaces, with the given annotation type. Returns null if the annotation
+     * type was not present on any of them.</p>
+     *
+     * <p>Stops searching for an annotation once the first annotation of the specified type has been
+     * found. i.e, additional annotations of the specified type will be silently ignored.</p>
+     * @param <A>
+     *            the annotation type
+     * @param method
+     *            the {@link Method} to query
+     * @param annotationCls
+     *            the {@link Annotation} to check if is present on the method
+     * @param searchSupers
+     *            determines if lookup in the entire inheritance hierarchy of the given class if was not directly present
+     * @param ignoreAccess
+     *            determines if underlying method has to be accessible
+     * @return the first matching annotation, or {@code null} if not found
+     * @throws IllegalArgumentException
+     *            if the method or annotation are {@code null}
+     * @since 3.6
+     */
+    public static <A extends Annotation> A getAnnotation(final Method method, final Class<A> annotationCls,
+                                                         boolean searchSupers, boolean ignoreAccess) {
+
+        Validate.isTrue(method != null, "The method must not be null");
+        Validate.isTrue(annotationCls != null, "The annotation class must not be null");
+        if(!ignoreAccess && !MemberUtils.isAccessible(method)) {
+            return null;
+        }
+
+        A annotation = method.getAnnotation(annotationCls);
+
+        if(annotation == null && searchSupers) {
+            Class<?> mcls = method.getDeclaringClass();
+            List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls);
+            for (Class<?> acls : classes) {
+                Method equivalentMethod;
+                try {
+                    equivalentMethod = (ignoreAccess ? acls.getDeclaredMethod(method.getName(), method.getParameterTypes())
+                            : acls.getMethod(method.getName(), method.getParameterTypes()));
+                } catch (NoSuchMethodException e) {
+                    // If not found, just keep on search
+                    continue;
+                }
+                annotation = equivalentMethod.getAnnotation(annotationCls);
+                if (annotation != null) {
+                    break;
+                }
+            }
+        }
+
+        return annotation;
+    }
+
+    /**
+     * <p>Gets a combination of {@link ClassUtils#getAllSuperclasses}(Class)} and
+     * {@link ClassUtils#getAllInterfaces}(Class)}, one from superclasses, one
+     * from interfaces, and so on in a breadth first way.</p>
+     *
+     * @param cls  the class to look up, may be {@code null}
+     * @return the combined {@code List} of superclasses and interfaces in order
+     * going up from this one
+     *  {@code null} if null input
+     * @since 3.6
+     */
+    private static List<Class<?>> getAllSuperclassesAndInterfaces(final Class<?> cls) {
+        if (cls == null) {
+            return null;
+        }
+
+        final List<Class<?>> classes = new ArrayList<>();
+        List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(cls);
+        int sci = 0;
+        List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(cls);
+        int ifi = 0;
+        while (ifi < allInterfaces.size() ||
+                sci < allSuperclasses.size()) {
+            Class<?> acls;
+            if (ifi >= allInterfaces.size()) {
+                acls = allSuperclasses.get(sci++);
+            } else if (sci >= allSuperclasses.size()) {
+                acls = allInterfaces.get(ifi++);
+            } else if (ifi < sci) {
+                acls = allInterfaces.get(ifi++);
+            } else if (sci < ifi) {
+                acls = allSuperclasses.get(sci++);
+            } else {
+                acls = allInterfaces.get(ifi++);
+            }
+            classes.add(acls);
+        }
+        return classes;
+    }
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46007c15/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
index df57a13..15d7cd7 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
@@ -47,6 +47,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
 import org.apache.commons.lang3.reflect.testbed.Annotated;
 import org.apache.commons.lang3.reflect.testbed.GenericConsumer;
 import org.apache.commons.lang3.reflect.testbed.GenericParent;
+import org.apache.commons.lang3.reflect.testbed.PublicChild;
 import org.apache.commons.lang3.reflect.testbed.StringParameterizedChild;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.junit.Assert;
@@ -681,6 +682,125 @@ public class MethodUtilsTest {
         assertThat(methodsWithAnnotation, hasItemInArray(MethodUtilsTest.class.getMethod("testGetMethodsListWithAnnotation")));
     }
 
+    @Test
+    public void testGetMethodsWithAnnotationSearchSupersAndIgnoreAccess() throws NoSuchMethodException {
+        assertArrayEquals(new Method[0], MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
+                true, true));
+
+        final Method[] methodsWithAnnotation = MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
+                true, true);
+        assertEquals(4, methodsWithAnnotation.length);
+        assertEquals("PublicChild", methodsWithAnnotation[0].getDeclaringClass().getSimpleName());
+        assertEquals("PublicChild", methodsWithAnnotation[1].getDeclaringClass().getSimpleName());
+        assertTrue(methodsWithAnnotation[0].getName().endsWith("AnnotatedMethod"));
+        assertTrue(methodsWithAnnotation[1].getName().endsWith("AnnotatedMethod"));
+        assertEquals("Foo.doIt",
+                methodsWithAnnotation[2].getDeclaringClass().getSimpleName() + '.' +
+                        methodsWithAnnotation[2].getName());
+        assertEquals("Parent.parentProtectedAnnotatedMethod",
+                methodsWithAnnotation[3].getDeclaringClass().getSimpleName() + '.' +
+                        methodsWithAnnotation[3].getName());
+    }
+
+    @Test
+    public void testGetMethodsWithAnnotationNotSearchSupersButIgnoreAccess() throws NoSuchMethodException {
+        assertArrayEquals(new Method[0], MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
+                false, true));
+
+        final Method[] methodsWithAnnotation = MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
+                false, true);
+        assertEquals(2, methodsWithAnnotation.length);
+        assertEquals("PublicChild", methodsWithAnnotation[0].getDeclaringClass().getSimpleName());
+        assertEquals("PublicChild", methodsWithAnnotation[1].getDeclaringClass().getSimpleName());
+        assertTrue(methodsWithAnnotation[0].getName().endsWith("AnnotatedMethod"));
+        assertTrue(methodsWithAnnotation[1].getName().endsWith("AnnotatedMethod"));
+    }
+
+    @Test
+    public void testGetMethodsWithAnnotationSearchSupersButNotIgnoreAccess() throws NoSuchMethodException {
+        assertArrayEquals(new Method[0], MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
+                true, false));
+
+        final Method[] methodsWithAnnotation = MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
+                true, false);
+        assertEquals(2, methodsWithAnnotation.length);
+        assertEquals("PublicChild.publicAnnotatedMethod",
+                methodsWithAnnotation[0].getDeclaringClass().getSimpleName() + '.' +
+                        methodsWithAnnotation[0].getName());
+        assertEquals("Foo.doIt",
+                methodsWithAnnotation[1].getDeclaringClass().getSimpleName() + '.' +
+                        methodsWithAnnotation[1].getName());
+    }
+
+    @Test
+    public void testGetMethodsWithAnnotationNotSearchSupersAndNotIgnoreAccess() throws NoSuchMethodException {
+        assertArrayEquals(new Method[0], MethodUtils.getMethodsWithAnnotation(Object.class, Annotated.class,
+                false, false));
+
+        final Method[] methodsWithAnnotation = MethodUtils.getMethodsWithAnnotation(PublicChild.class, Annotated.class,
+                false, false);
+        assertEquals(1, methodsWithAnnotation.length);
+        assertEquals("PublicChild.publicAnnotatedMethod",
+                methodsWithAnnotation[0].getDeclaringClass().getSimpleName() + '.' +
+                        methodsWithAnnotation[0].getName());
+    }
+
+    @Test
+    public void testGetAnnotationSearchSupersAndIgnoreAccess() throws NoSuchMethodException {
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentNotAnnotatedMethod"),
+                Annotated.class, true, true));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("doIt"), Annotated.class,
+                true, true));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentProtectedAnnotatedMethod"),
+                Annotated.class, true, true));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getDeclaredMethod("privateAnnotatedMethod"),
+                Annotated.class, true, true));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("publicAnnotatedMethod"),
+                Annotated.class, true, true));
+    }
+
+    @Test
+    public void testGetAnnotationNotSearchSupersButIgnoreAccess() throws NoSuchMethodException {
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentNotAnnotatedMethod"),
+                Annotated.class, false, true));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("doIt"), Annotated.class,
+                false, true));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentProtectedAnnotatedMethod"),
+                Annotated.class, false, true));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getDeclaredMethod("privateAnnotatedMethod"),
+                Annotated.class, false, true));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("publicAnnotatedMethod"),
+                Annotated.class, false, true));
+    }
+
+    @Test
+    public void testGetAnnotationSearchSupersButNotIgnoreAccess() throws NoSuchMethodException {
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentNotAnnotatedMethod"),
+                Annotated.class, true, false));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("doIt"), Annotated.class,
+                true, false));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentProtectedAnnotatedMethod"),
+                Annotated.class, true, false));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getDeclaredMethod("privateAnnotatedMethod"),
+                Annotated.class, true, false));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("publicAnnotatedMethod"),
+                Annotated.class, true, false));
+    }
+
+    @Test
+    public void testGetAnnotationNotSearchSupersAndNotIgnoreAccess() throws NoSuchMethodException {
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentNotAnnotatedMethod"),
+                Annotated.class, false, false));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("doIt"), Annotated.class,
+                false, false));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("parentProtectedAnnotatedMethod"),
+                Annotated.class, false, false));
+        assertNull(MethodUtils.getAnnotation(PublicChild.class.getDeclaredMethod("privateAnnotatedMethod"),
+                Annotated.class, false, false));
+        assertNotNull(MethodUtils.getAnnotation(PublicChild.class.getMethod("publicAnnotatedMethod"),
+                Annotated.class, false, false));
+    }
+
     @Test(expected = IllegalArgumentException.class)
     public void testGetMethodsWithAnnotationIllegalArgumentException1() {
         MethodUtils.getMethodsWithAnnotation(FieldUtilsTest.class, null);
@@ -724,6 +844,22 @@ public class MethodUtilsTest {
         MethodUtils.getMethodsListWithAnnotation(null, null);
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetAnnotationIllegalArgumentException1() {
+        MethodUtils.getAnnotation(FieldUtilsTest.class.getDeclaredMethods()[0], null, true,
+                true);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetAnnotationIllegalArgumentException2() {
+        MethodUtils.getAnnotation(null, Annotated.class, true, true);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetAnnotationIllegalArgumentException3() {
+        MethodUtils.getAnnotation(null, null, true, true);
+    }
+
     private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls,
             final String methodName, final Class<?>[] requestTypes, final Class<?>[] actualTypes) {
         final Method m = MethodUtils.getMatchingAccessibleMethod(cls, methodName,

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46007c15/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java b/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java
index 5511993..be24ac6 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java
@@ -21,5 +21,6 @@ package org.apache.commons.lang3.reflect.testbed;
 public interface Foo {
     public static final String VALUE = "foo";
 
+    @Annotated
     void doIt();
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46007c15/src/test/java/org/apache/commons/lang3/reflect/testbed/Parent.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/testbed/Parent.java b/src/test/java/org/apache/commons/lang3/reflect/testbed/Parent.java
index 70447b4..eeee5e3 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/testbed/Parent.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/testbed/Parent.java
@@ -28,4 +28,11 @@ class Parent implements Foo {
     @Override
     public void doIt() {
     }
+
+    @Annotated
+    protected void parentProtectedAnnotatedMethod() {
+    }
+
+    public void parentNotAnnotatedMethod() {
+    }
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/46007c15/src/test/java/org/apache/commons/lang3/reflect/testbed/PublicChild.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/testbed/PublicChild.java b/src/test/java/org/apache/commons/lang3/reflect/testbed/PublicChild.java
index c91a06f..ce2a1ec 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/testbed/PublicChild.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/testbed/PublicChild.java
@@ -20,4 +20,20 @@ package org.apache.commons.lang3.reflect.testbed;
  */
 public class PublicChild extends Parent {
     static final String VALUE = "child";
+
+    @Override
+    public void parentProtectedAnnotatedMethod() {
+    }
+
+    @Override
+    public void parentNotAnnotatedMethod() {
+    }
+
+    @Annotated
+    private void privateAnnotatedMethod() {
+    }
+
+    @Annotated
+    public void publicAnnotatedMethod() {
+    }
 }


[03/50] [lang] LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest

Posted by br...@apache.org.
LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest


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

Branch: refs/heads/release
Commit: 3c2673e82d33b6c9bef3005a896e5b0d52b108dd
Parents: 661d16d
Author: MarkDacek <ma...@richmond.edu>
Authored: Sat Mar 18 16:00:46 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sat Mar 18 16:00:46 2017 -0400

----------------------------------------------------------------------
 ...ionToStringBuilderExcludeNullValuesTest.java | 51 ++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/3c2673e8/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
index be368d6..7c0c68a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -72,10 +72,8 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
     
     @Test
     public void test_ConstructorOption(){
-        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, false);
-        builder.setExcludeNullValues(true);
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, true);
         assertTrue(builder.isExcludeNullValues());
-        
         String toString = builder.toString();
         assertTrue(toString.contains(INTEGER_FIELD_NAME));
         assertTrue(toString.contains(STRING_FIELD_NAME));
@@ -95,5 +93,52 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
         assertFalse(toString.contains(INTEGER_FIELD_NAME));
         assertFalse(toString.contains(STRING_FIELD_NAME));
     }
+    
+    @Test
+    public void test_ConstructorOptionNormal(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
+        assertFalse(builder.isExcludeNullValues());
+        String toString = builder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        //regression test older constructors
+        ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_ConstructorOption_ExcludeNull(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
+        builder.setExcludeNullValues(true);
+        assertTrue(builder.isExcludeNullValues());
+        String toString = builder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        
+        ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
+        oldBuilder.setExcludeNullValues(true);
+        assertTrue(oldBuilder.isExcludeNullValues());
+        toString = oldBuilder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+    }
 
 }


[50/50] [lang] Update version numbers for release 3.6

Posted by br...@apache.org.
Update version numbers for release 3.6


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

Branch: refs/heads/release
Commit: 3a64cf6aff408a9cbdcb4d7456360a97d1a880f0
Parents: cc06d26
Author: Benedikt Ritter <br...@apache.org>
Authored: Mon Apr 17 14:17:38 2017 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:59:25 2017 -0400

----------------------------------------------------------------------
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/3a64cf6a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 09607c8..a204199 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>commons-lang3</artifactId>
-  <version>3.6-SNAPSHOT</version>
+  <version>3.6</version>
   <name>Apache Commons Lang</name>
 
   <inceptionYear>2001</inceptionYear>
@@ -47,7 +47,7 @@
     <connection>scm:git:http://git-wip-us.apache.org/repos/asf/commons-lang.git</connection>
     <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/commons-lang.git</developerConnection>
     <url>https://git-wip-us.apache.org/repos/asf?p=commons-lang.git</url>
-    <tag>HEAD</tag>
+    <tag>LANG_3_6</tag>
   </scm>
 
   <developers>


[14/50] [lang] LANG-1272: Added shuffle methods to ArrayUtils

Posted by br...@apache.org.
LANG-1272: Added shuffle methods to ArrayUtils


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

Branch: refs/heads/release
Commit: 82cc24437f43d07880d8883229477735431e5d02
Parents: 9ceaaeb
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Wed Apr 19 18:53:06 2017 +0200
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Wed Apr 19 18:54:23 2017 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |   1 +
 .../org/apache/commons/lang3/ArrayUtils.java    | 226 +++++++++++++++++++
 .../apache/commons/lang3/ArrayUtilsTest.java    | 105 +++++++++
 3 files changed, 332 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/82cc2443/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5724717..f16bb26 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -83,6 +83,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1316" type="update" dev="pschumacher">Deprecate classes/methods moved to commons-text</action>
     <action issue="LANG-1310" type="fix" dev="pschumacher" due-to="Don Jeba">MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines</action>
     <action issue="LANG-1313" type="add" dev="pschumacher" due-to="Tomschi">Add ArchUtils - An utility class for the "os.arch" system property</action>
+    <action issue="LANG-1272" type="add" dev="ebourg">Add shuffle methods to ArrayUtils</action>
   </release>
 
   <release version="3.5" date="2016-10-13" description="New features including Java 9 detection">

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/82cc2443/src/main/java/org/apache/commons/lang3/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index afcb27f..f0e9f6b 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -22,6 +22,7 @@ import java.util.BitSet;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Random;
 
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -8445,4 +8446,229 @@ public class ArrayUtils {
         }
         return result;
     }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(Object[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(Object[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(boolean[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(boolean[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(byte[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(byte[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(char[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(char[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(short[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(short[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(int[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(int[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(long[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(long[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(float[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(float[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(double[] array) {
+        shuffle(array, new Random());
+    }
+
+    /**
+     * Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
+     *
+     * @param array   the array to shuffle
+     * @param random  the source of randomness used to permute the elements
+     * @see <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle algorithm</a>
+     * @since 3.6
+     */
+    public static void shuffle(double[] array, Random random) {
+        for (int i = array.length; i > 1; i--) {
+            swap(array, i - 1, random.nextInt(i), 1);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/82cc2443/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index 9388e24..a2d3a21 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -4990,4 +4990,109 @@ public class ArrayUtilsTest  {
                 ArrayUtils.toStringArray(array, "valueForNullElements"));
     }
 
+    @Test
+    public void testShuffle() {
+        String[] array1 = new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
+        String[] array2 = ArrayUtils.clone(array1);
+
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (String element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleBoolean() {
+        boolean[] array1 = new boolean[]{true, false, true, true, false, false, true, false, false, true};
+        boolean[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        Assert.assertEquals(5, ArrayUtils.removeAllOccurences(array1, true).length);
+    }
+
+    @Test
+    public void testShuffleByte() {
+        byte[] array1 = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        byte[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (byte element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleChar() {
+        char[] array1 = new char[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        char[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (char element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleShort() {
+        short[] array1 = new short[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        short[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (short element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleInt() {
+        int[] array1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        int[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (int element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleLong() {
+        long[] array1 = new long[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        long[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (long element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleFloat() {
+        float[] array1 = new float[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        float[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (float element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
+
+    @Test
+    public void testShuffleDouble() {
+        double[] array1 = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        double[] array2 = ArrayUtils.clone(array1);
+        
+        ArrayUtils.shuffle(array1);
+        Assert.assertFalse(Arrays.equals(array1, array2));
+        for (double element : array2) {
+            Assert.assertTrue("Element " + element + " not found", ArrayUtils.contains(array1, element));
+        }
+    }
 }


[23/50] [lang] Use String#contains where possible (closes #263)

Posted by br...@apache.org.
Use String#contains where possible (closes #263)

Since the project defines a JDK 7 source compatibility, it's safe to use JDK 5's features.
This patch replaces usages of String#indexOf with String#contains where possible to make the code easier to read and maintain.


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

Branch: refs/heads/release
Commit: d5be24a12668a94712247d31f06ef7d416b8118c
Parents: 8cafd87
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 22 22:59:38 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sat Apr 22 22:18:16 2017 +0200

----------------------------------------------------------------------
 .../ReflectionToStringBuilderExcludeTest.java   |  4 +--
 .../exception/AbstractExceptionContextTest.java | 24 +++++++++---------
 .../lang3/exception/ContextedExceptionTest.java | 26 ++++++++++----------
 .../ContextedRuntimeExceptionTest.java          | 26 ++++++++++----------
 .../lang3/exception/ExceptionUtilsTest.java     |  8 +++---
 5 files changed, 44 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
index 75b80b2..c36d254 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java
@@ -120,8 +120,8 @@ public class ReflectionToStringBuilderExcludeTest {
     }
 
     private void validateNonSecretField(final String toString) {
-        Assert.assertTrue(toString.indexOf(NOT_SECRET_FIELD) > ArrayUtils.INDEX_NOT_FOUND);
-        Assert.assertTrue(toString.indexOf(NOT_SECRET_VALUE) > ArrayUtils.INDEX_NOT_FOUND);
+        Assert.assertTrue(toString.contains(NOT_SECRET_FIELD));
+        Assert.assertTrue(toString.contains(NOT_SECRET_VALUE));
     }
 
     private void validateSecretFieldAbsent(final String toString) {

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
index 6787bb5..85b5243 100644
--- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
@@ -63,13 +63,13 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
     @Test
     public void testAddContextValue() {
         final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
-        assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
-        assertTrue(message.indexOf("test1") >= 0);
-        assertTrue(message.indexOf("test2") >= 0);
-        assertTrue(message.indexOf("test Date") >= 0);
-        assertTrue(message.indexOf("test Nbr") >= 0);
-        assertTrue(message.indexOf("some value") >= 0);
-        assertTrue(message.indexOf("5") >= 0);
+        assertTrue(message.contains(TEST_MESSAGE));
+        assertTrue(message.contains("test1"));
+        assertTrue(message.contains("test2"));
+        assertTrue(message.contains("test Date"));
+        assertTrue(message.contains("test Nbr"));
+        assertTrue(message.contains("some value"));
+        assertTrue(message.contains("5"));
 
         assertTrue(exceptionContext.getFirstContextValue("test1") == null);
         assertTrue(exceptionContext.getFirstContextValue("test2").equals("some value"));
@@ -85,7 +85,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
         assertTrue(exceptionContext.getContextLabels().contains("test2"));
 
         final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
-        assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
+        assertTrue(!contextMessage.contains(TEST_MESSAGE));
     }
 
     @Test
@@ -94,9 +94,9 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
         exceptionContext.setContextValue("test3", "3");
 
         final String message = exceptionContext.getFormattedExceptionMessage(TEST_MESSAGE);
-        assertTrue(message.indexOf(TEST_MESSAGE) >= 0);
-        assertTrue(message.indexOf("test Poorly written obj") >= 0);
-        assertTrue(message.indexOf("Crap") >= 0);
+        assertTrue(message.contains(TEST_MESSAGE));
+        assertTrue(message.contains("test Poorly written obj"));
+        assertTrue(message.contains("Crap"));
 
         assertTrue(exceptionContext.getFirstContextValue("crap") == null);
         assertTrue(exceptionContext.getFirstContextValue("test Poorly written obj") instanceof ObjectWithFaultyToString);
@@ -118,7 +118,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
         assertEquals(6, exceptionContext.getContextLabels().size());
 
         final String contextMessage = exceptionContext.getFormattedExceptionMessage(null);
-        assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
+        assertTrue(!contextMessage.contains(TEST_MESSAGE));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
index 48703a5..75b66ab 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
@@ -41,7 +41,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
         exceptionContext = new ContextedException();
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
+        assertTrue(trace.contains("ContextedException"));
         assertTrue(StringUtils.isEmpty(message));
     }
 
@@ -51,7 +51,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
         assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
         
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
+        assertTrue(trace.contains(TEST_MESSAGE));
     }
 
     @Test
@@ -59,9 +59,9 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
         exceptionContext = new ContextedException(new Exception(TEST_MESSAGE));
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
-        assertTrue(message.indexOf(TEST_MESSAGE)>=0);
+        assertTrue(trace.contains("ContextedException"));
+        assertTrue(trace.contains(TEST_MESSAGE));
+        assertTrue(message.contains(TEST_MESSAGE));
     }
 
     @Test
@@ -69,10 +69,10 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
         exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
-        assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
+        assertTrue(trace.contains("ContextedException"));
+        assertTrue(trace.contains(TEST_MESSAGE));
+        assertTrue(trace.contains(TEST_MESSAGE_2));
+        assertTrue(message.contains(TEST_MESSAGE_2));
     }
     
     @Test
@@ -80,10 +80,10 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
         exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
-        assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
+        assertTrue(trace.contains("ContextedException"));
+        assertTrue(trace.contains(TEST_MESSAGE));
+        assertTrue(trace.contains(TEST_MESSAGE_2));
+        assertTrue(message.contains(TEST_MESSAGE_2));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
index 6f3b066..c10b1e8 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
@@ -43,7 +43,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
         exceptionContext = new ContextedRuntimeException();
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
+        assertTrue(trace.contains("ContextedException"));
         assertTrue(StringUtils.isEmpty(message));
     }
 
@@ -53,7 +53,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
         assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
         
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
+        assertTrue(trace.contains(TEST_MESSAGE));
     }
 
     @Test
@@ -61,9 +61,9 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
         exceptionContext = new ContextedRuntimeException(new Exception(TEST_MESSAGE));
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
-        assertTrue(message.indexOf(TEST_MESSAGE)>=0);
+        assertTrue(trace.contains("ContextedException"));
+        assertTrue(trace.contains(TEST_MESSAGE));
+        assertTrue(message.contains(TEST_MESSAGE));
     }
 
     @Test
@@ -71,10 +71,10 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
         exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE));
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
-        assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
+        assertTrue(trace.contains("ContextedException"));
+        assertTrue(trace.contains(TEST_MESSAGE));
+        assertTrue(trace.contains(TEST_MESSAGE_2));
+        assertTrue(message.contains(TEST_MESSAGE_2));
     }
     
     @Test
@@ -84,10 +84,10 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
         new DefaultExceptionContext() {private static final long serialVersionUID = 1L;});
         final String message = exceptionContext.getMessage();
         final String trace = ExceptionUtils.getStackTrace(exceptionContext);
-        assertTrue(trace.indexOf("ContextedException")>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE)>=0);
-        assertTrue(trace.indexOf(TEST_MESSAGE_2)>=0);
-        assertTrue(message.indexOf(TEST_MESSAGE_2)>=0);
+        assertTrue(trace.contains("ContextedException"));
+        assertTrue(trace.contains(TEST_MESSAGE));
+        assertTrue(trace.contains(TEST_MESSAGE_2));
+        assertTrue(message.contains(TEST_MESSAGE_2));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d5be24a1/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index f1eb4d7..7a4cf9d 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
@@ -388,12 +388,12 @@ public class ExceptionUtilsTest {
         final Throwable cause = createExceptionWithCause();
         ExceptionUtils.printRootCauseStackTrace(cause, new PrintStream(out));
         String stackTrace = out.toString();
-        assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
+        assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
         
         out = new ByteArrayOutputStream(1024);
         ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintStream(out));
         stackTrace = out.toString();
-        assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) == -1);
+        assertTrue(!stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
     }
 
     @Test
@@ -414,12 +414,12 @@ public class ExceptionUtilsTest {
         final Throwable cause = createExceptionWithCause();
         ExceptionUtils.printRootCauseStackTrace(cause, new PrintWriter(writer));
         String stackTrace = writer.toString();
-        assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) != -1);
+        assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
         
         writer = new StringWriter(1024);
         ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintWriter(writer));
         stackTrace = writer.toString();
-        assertTrue(stackTrace.indexOf(ExceptionUtils.WRAPPED_MARKER) == -1);
+        assertTrue(!stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
     }
 
     //-----------------------------------------------------------------------


[28/50] [lang] LANG-1256: Add JMH maven dependencies.

Posted by br...@apache.org.
LANG-1256: Add JMH maven dependencies.

fix checkstyle exclusion on older maven versions


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

Branch: refs/heads/release
Commit: b7cc7a1c7ba803e37218e53825c8aa1534071796
Parents: 331d2f2
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Apr 28 19:09:14 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 28 19:09:14 2017 +0200

----------------------------------------------------------------------
 pom.xml | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/b7cc7a1c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0f842fc..35cf5b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -675,10 +675,14 @@
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
-          <!-- necessary to exclude classes generated by JMH for check -->
+          <!-- start: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
+          <sourceDirectories>
+            <sourceDirectory>src/main/java</sourceDirectory>
+          </sourceDirectories>
           <testSourceDirectories>
             <testSourceDirectory>src/test/java</testSourceDirectory>
           </testSourceDirectories>
+          <!-- end: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>
@@ -704,10 +708,14 @@
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
-          <!-- necessary to exclude classes generated by JMH for check -->
+          <!-- start: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
+          <sourceDirectories>
+            <sourceDirectory>src/main/java</sourceDirectory>
+          </sourceDirectories>
           <testSourceDirectories>
             <testSourceDirectory>src/test/java</testSourceDirectory>
           </testSourceDirectories>
+          <!-- end: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>


[05/50] [lang] [LANG-1291] Provide annotations to document thread safety.

Posted by br...@apache.org.
[LANG-1291] Provide annotations to document thread safety.

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

Branch: refs/heads/release
Commit: a5e76ebc404d419651c2a25b1a62199de64cccf5
Parents: 5242157
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Apr 17 11:54:04 2017 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Mon Apr 17 11:54:04 2017 -0700

----------------------------------------------------------------------
 .../lang3/concurrent/annotation/Contract.java   | 50 +++++++++++++++
 .../annotation/ThreadingBehavior.java           | 66 ++++++++++++++++++++
 2 files changed, 116 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a5e76ebc/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java
new file mode 100644
index 0000000..e34bb95
--- /dev/null
+++ b/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java
@@ -0,0 +1,50 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.commons.lang3.concurrent.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation defines behavioral contract enforced at runtime by instances of annotated classes.
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface Contract {
+
+    /**
+     * Defines behavioral contract enforced at runtime by instances of annotated classes.
+     * 
+     * @return The behavioral contract enforced at runtime by instances of annotated classes.
+     */
+    ThreadingBehavior threading() default ThreadingBehavior.UNSAFE;
+
+}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a5e76ebc/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java
new file mode 100644
index 0000000..e03b164
--- /dev/null
+++ b/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java
@@ -0,0 +1,66 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.commons.lang3.concurrent.annotation;
+
+/**
+ * Defines types of threading behavior enforced at runtime.
+ */
+public enum ThreadingBehavior {
+
+    /**
+     * Instances of classes with the given contract are expected to be fully immutable and thread-safe.
+     */
+    IMMUTABLE,
+
+    /**
+     * Instances of classes with the given contract are expected to be immutable if their dependencies injected at
+     * construction time are immutable and are expected to be thread-safe if their dependencies are thread-safe.
+     */
+    IMMUTABLE_CONDITIONAL,
+
+    /**
+     * Instances of classes with the given contract are expected to maintain no state and to be thread-safe.
+     */
+    STATELESS,
+
+    /**
+     * Instances of classes with the given contract are expected to be fully thread-safe.
+     */
+    SAFE,
+
+    /**
+     * Instances of classes with the given contract are expected to be thread-safe if their dependencies injected at
+     * construction time are thread-safe.
+     */
+    SAFE_CONDITIONAL,
+
+    /**
+     * Instances of classes with the given contract are expected to be non thread-safe.
+     */
+    UNSAFE
+
+}


[12/50] [lang] Add a default case to switch to appease FindBugs

Posted by br...@apache.org.
Add a default case to switch to appease FindBugs


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

Branch: refs/heads/release
Commit: 9f7d03f09172afcf0a7be40e3262d151ef053b3c
Parents: 8069e1c
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:16:52 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:58 2017 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/time/FastDateParser.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9f7d03f0/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
index e27acf4..9cf1a1c 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
@@ -863,6 +863,8 @@ public class FastDateParser implements DateParser, Serializable {
                     case 5: // offset 5 starts additional names, probably standard time
                         tzInfo = standard;
                         break;
+                    default:
+                        break;
                     }
                     if (zoneNames[i] != null) {
                         final String key = zoneNames[i].toLowerCase(locale);


[26/50] [lang] LANG-1110: Implement HashSetvBitSetTest using JMH

Posted by br...@apache.org.
LANG-1110: Implement HashSetvBitSetTest using JMH

(side effect: closes #253, closes #191)


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

Branch: refs/heads/release
Commit: e685d847b4c70e354e47ea3990cefda3265aa5c6
Parents: 111fd3f
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Apr 28 17:36:58 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 28 17:36:58 2017 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |   2 +
 .../commons/lang3/HashSetvBitSetTest.java       | 156 +++++--------------
 2 files changed, 41 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e685d847/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f4df009..a679df8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,8 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.6" date="2017-MM-DD" description="TBD">
+    <action issue="LANG-1110" type="update" dev="pschumacher" due-to="Bruno P. Kinoshita">Implement HashSetvBitSetTest using JMH</action>
+    <action issue="LANG-1256" type="add" dev="pschumacher" due-to="C0rWin">Add JMH maven dependencies</action>
     <action issue="LANG-1167" type="add" dev="chtompki" due-to="Mark Dacek">Add null filter to ReflectionToStringBuilder</action>
     <action issue="LANG-1312" type="fix" dev="britter">LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code followed by variant</action>
     <action issue="LANG-1300" type="fix" dev="chtompki" due-to="Mark Dacek">Clarify or improve behaviour of int-based indexOf methods in StringUtils</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e685d847/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
index 994631f..cafb298 100644
--- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
+++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java
@@ -18,86 +18,63 @@ package org.apache.commons.lang3;
 
 import java.util.BitSet;
 import java.util.HashSet;
+import java.util.concurrent.TimeUnit;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
 
 /**
  * Test to show whether using BitSet for removeAll() methods is faster than using HashSet.
  */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
 public class HashSetvBitSetTest {
 
-    private static final int LOOPS = 2000; // number of times to invoke methods
-    private static final int LOOPS2 = 10000;
+    private static final int numberOfElementsToCompute = 10;
 
-    @Test
-    public void testTimes() {
-        timeHashSet(10); // warmup
-        timeBitSet(10); // warmup
-        long timeDiff = printTimes(0);
-        timeDiff += printTimes(5);
-        timeDiff += printTimes(10);
-        timeDiff += printTimes(200);
-        timeDiff += printTimes(50);
-        timeDiff += printTimes(100);
-        timeDiff += printTimes(1000);
-        timeDiff += printTimes(2000);
-        Assert.assertTrue(timeDiff <= 0);
-    }
-
-    /**
-     * @return bitSet - HashSet
-     */
-    private long printTimes(final int count) {
-        final long hashSet = timeHashSet(count);
-        final long bitSet = timeBitSet(count);
-        // If percent is less than 100, then bitset is faster
-        System.out.println("Ratio="+(bitSet*100/hashSet)+"% count="+count+" hash="+hashSet+" bits="+bitSet);
-        return bitSet - hashSet;
-    }
-
-    private static long timeHashSet(final int count) {
-        int [] result = new int[0];
-        final long start = System.nanoTime();
-        for (int i = 0; i < LOOPS; i++) {
-            result = testHashSet(count);
-        }
-        final long elapsed = System.nanoTime() - start;
-        Assert.assertEquals(count, result.length);
-        return elapsed;
-    }
-
-    private static long timeBitSet(final int count) {
-        int [] result = new int[0];
-        final long start = System.nanoTime();
-        for (int i = 0; i < LOOPS; i++) {
-            result = testBitSet(count);
+    @Benchmark
+    public int[] testHashSet() {
+        final HashSet<Integer> toRemove = new HashSet<Integer>();
+        int found = 0;
+        for (int i = 0; i < numberOfElementsToCompute; i++) {
+            toRemove.add(found++);
         }
-        final long elapsed = System.nanoTime() - start;
-        Assert.assertEquals(count, result.length);
-        return elapsed;
+        return extractIndices(toRemove);
     }
 
-    @SuppressWarnings("boxing")
-    private static int[] testHashSet(final int count) {
-        final HashSet<Integer> toRemove = new HashSet<>();
-            int found = 0;
-            for (int i = 0; i < count; i++) {
-                toRemove.add(found++);
-            }
-            return extractIndices(toRemove);
-        }
-    
-    private static int[] testBitSet(final int count) {
+    @Benchmark
+    public int[] testBitSet() {
         final BitSet toRemove = new BitSet();
         int found = 0;
-        for (int i = 0; i < count; i++) {
+        for (int i = 0; i < numberOfElementsToCompute; i++) {
             toRemove.set(found++);
         }
         return extractIndices(toRemove);
     }
+
+    @Benchmark
+    public int[] timeBitSetRemoveAll() {
+        final BitSet toRemove = new BitSet();
+        final int[] array = new int[100];
+        toRemove.set(10, 20);
+        return (int[]) ArrayUtils.removeAll(array, toRemove);
+    }
     
+    @Benchmark
+    public int[] timeExtractRemoveAll() {
+        final BitSet toRemove = new BitSet();
+        final int[] array = new int[100];
+        toRemove.set(10, 20);
+        final int[] extractIndices = extractIndices(toRemove);
+        return (int[]) ArrayUtils.removeAll((Object)array, extractIndices);
+    }
 
+    // --- utility methods
     private static int[] extractIndices(final HashSet<Integer> coll) {
         final int[] result = new int[coll.size()];
         int i = 0;
@@ -116,59 +93,4 @@ public class HashSetvBitSetTest {
         }
         return result;
     }
-    
-    @Test
-    public void testTimesExtractOrBitset() {
-        final BitSet toRemove = new BitSet();
-        final int[] array = new int[100];
-        toRemove.set(10, 20);
-        timeBitSetRemoveAll(array, toRemove); // warmup
-        timeExtractRemoveAll(array, toRemove); // warmup
-        long timeDiff = printTimes(100,1);
-        timeDiff += printTimes(100,10);
-        timeDiff += printTimes(100,50);
-        timeDiff += printTimes(100,100);
-        timeDiff += printTimes(1000,10);
-        timeDiff += printTimes(1000,100);
-        timeDiff += printTimes(1000,500);
-        timeDiff += printTimes(1000,1000);
-        Assert.assertTrue(timeDiff <= 0);
-    }
-
-    private long printTimes(final int arraySize, final int bitSetSize) {
-        final int[] array = new int[arraySize];
-        final BitSet remove = new BitSet();
-        for (int i = 0; i < bitSetSize; i++) {
-            remove.set(i);
-        }
-        final long bitSet = timeBitSetRemoveAll(array, remove );
-        final long extract = timeExtractRemoveAll(array, remove);
-        // If percent is less than 100, then direct use of bitset is faster
-        System.out.println("Ratio="+(bitSet*100/extract)+"% array="+array.length+" count="+remove.cardinality()+" extract="+extract+" bitset="+bitSet);
-        return bitSet - extract;
-    }
-
-    private long timeBitSetRemoveAll(final int[] array, final BitSet toRemove) {
-        int[] output = new int[0];
-        final long start = System.nanoTime();
-        for(int i = 0; i < LOOPS2; i++){
-            output = (int[]) ArrayUtils.removeAll(array, toRemove);            
-        }
-        final long end = System.nanoTime();
-        Assert.assertEquals(array.length-toRemove.cardinality(), output.length);
-        return end - start;
-    }
-    
-    private long timeExtractRemoveAll(final int[] array, final BitSet toRemove) {
-        int[] output = new int[0];
-        final long start = System.nanoTime();
-        for(int i = 0; i < LOOPS2; i++){
-            final int[] extractIndices = extractIndices(toRemove);
-            output = (int[]) ArrayUtils.removeAll((Object)array, extractIndices);
-        }
-        final long end = System.nanoTime();
-        Assert.assertEquals(array.length-toRemove.cardinality(), output.length);
-        return end - start;
-    }
-    
-}
\ No newline at end of file
+}


[48/50] [lang] Add release notes for 3.6 release

Posted by br...@apache.org.
Add release notes for 3.6 release


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

Branch: refs/heads/release
Commit: 964496a1b25ef55e8ffdc50f607408f5094fdabb
Parents: 02f3094
Author: Benedikt Ritter <br...@apache.org>
Authored: Mon Apr 17 14:05:42 2017 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:49:50 2017 -0400

----------------------------------------------------------------------
 RELEASE-NOTES.txt | 136 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 132 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/964496a1/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 141203a..3afdb1f 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,15 +1,16 @@
                            Apache Commons Lang
-                               Version 3.5
+                               Version 3.6
                               Release Notes
 
 
 INTRODUCTION:
 
-This document contains the release notes for the 3.5 version of
+This document contains the release notes for the 3.6 version of
 Apache Commons Lang as well as a history all changes in the Commons Lang 3.x
 release line. Commons Lang is a set of utility functions and reusable
-components that should be of use in any Java environment. Commons Lang 3.5 at
-least requires Java 6.0.
+components that should be of use in any Java environment. Commons Lang 3.6 at
+least requires Java 7. Note that this has changed from Commons Lang 3.5, which
+only required Java 1.6.
 
 For the advice on upgrading from 2.x to 3.x, see the following page:
 
@@ -20,6 +21,133 @@ HIGHLIGHTS
 
 Some of the highlights in this release include:
 
+o The class org.apache.commons.lang3.concurrent.Memoizer is an implementation
+    of the Memoizer pattern as shown in
+    Goetz, Brian et al. (2006) - Java Concurrency in Practice, p. 108.
+o The class org.apache.commons.lang3.ArchUtils has been added. ArchUtils is
+    a utility class for the "os.arch" system property.
+
+DEPRECATIONS
+============
+
+The Apache Commons Community has recently set up the Commons Text component
+as a home for algorithms working on strings. For this reason most of the string
+focused functionality in Commons Lang has been deprecated and moved to
+Commons Text. This includes:
+
+o Most of the classes in the org.apache.commons.lang3.text package
+o org.apache.commons.lang3.StringEscapeUtils
+o org.apache.commons.lang3.StringUtils.getJaroWinklerDistance and
+    org.apache.commons.lang3.StringUtils.getLevenshteinDistance
+
+For more information see the Commons Text website:
+
+    http://commons.apache.org/text
+
+BUILDING ON JAVA 9
+==================
+
+The build problems present in the 3.5 release have been resolved. Building
+Commons Lang 3.6 should work out of the box with the latest Java 9 EA build.
+Please report any Java 9 related issues at:
+
+    https://issues.apache.org/jira/browse/LANG
+
+NEW FEATURES
+============
+
+o LANG-1325: Increase test coverage of ToStringBuilder class to 100%.
+             Thanks to Arshad Basha.
+o LANG-1307: Add a method in StringUtils to extract only digits out of input
+             string. Thanks to Arshad Basha.
+o LANG-1256: Add JMH maven dependencies. Thanks to C0rWin.
+o LANG-1167: Add null filter to ReflectionToStringBuilder.
+             Thanks to Mark Dacek.
+o LANG-1299: Add method for converting string to an array of code points.
+o LANG-660:  Add methods to insert arrays into arrays at an index.
+o LANG-1034: Add support for recursive comparison to
+             EqualsBuilder#reflectionEquals. Thanks to Yathos UG.
+o LANG-1067: Add a reflection-based variant of DiffBuilder.
+o LANG-740:  Implementation of a Memomizer. Thanks to James Sawle.
+o LANG-1258: Add ArrayUtils#toStringArray method.
+             Thanks to IG, Grzegorz Rożniecki.
+o LANG-1160: StringUtils#abbreviate should support 'custom ellipses' parameter.
+o LANG-1293: Add StringUtils#isAllEmpty and #isAllBlank methods.
+             Thanks to Pierre Templier, Martin Tarjanyi.
+o LANG-1313: Add ArchUtils - An utility class for the "os.arch" system property.
+             Thanks to Tomschi.
+o LANG-1272: Add shuffle methods to ArrayUtils.
+o LANG-1317: Add MethodUtils#findAnnotation and extend
+             MethodUtils#getMethodsWithAnnotation for non-public, super-class
+             and interface methods. Thanks to Yasser Zamani.
+o LANG-1331: Add ImmutablePair.nullPair().
+o LANG-1332: Add ImmutableTriple.nullTriple().
+
+FIXED BUGS
+==========
+
+o LANG-1312: LocaleUtils#toLocale does not support language followed by UN M.49
+             numeric-3 area code followed by variant.
+o LANG-1300: Clarify or improve behaviour of int-based indexOf methods in
+             StringUtils. Thanks to Mark Dacek.
+o LANG-1286: RandomStringUtils random method can overflow and return characters
+             outside of specified range.
+o LANG-1292: WordUtils.wrap throws StringIndexOutOfBoundsException.
+o LANG-1287: RandomStringUtils#random can enter infinite loop if end parameter
+             is to small. Thanks to Ivan Morozov.
+o LANG-1285: NullPointerException in FastDateParser$TimeZoneStrategy.
+             Thanks to Francesco Chicchiriccò.
+o LANG-1281: Javadoc of StringUtils.ordinalIndexOf is contradictory.
+             Thanks to Andreas Lundblad.
+o LANG-1188: StringUtils#join(T...): warning: [unchecked] Possible heap
+             pollution from parameterized vararg type T.
+o LANG-1144: Multiple calls of
+             org.apache.commons.lang3.concurrent.LazyInitializer.initialize()
+             are possible. Thanks to Waldemar Maier, Gary Gregory.
+o LANG-1276: StrBuilder#replaceAll ArrayIndexOutOfBoundsException.
+             Thanks to Andy Klimczak.
+o LANG-1278: BooleanUtils javadoc issues. Thanks to Duke Yin.
+o LANG-1070: ArrayUtils#add confusing example in javadoc.
+             Thanks to Paul Pogonyshev.
+o LANG-1271: StringUtils#isAnyEmpty and #isAnyBlank should return false for an
+             empty array. Thanks to Pierre Templier.
+o LANG-1155: Add StringUtils#unwrap. Thanks to Saif Asif, Thiago Andrade.
+o LANG-1311: TypeUtils.toString() doesn't handle primitive and Object arrays
+             correctly. Thanks to Aaron Digulla.
+o LANG-1312: LocaleUtils#toLocale does not support language followed by UN M.49
+             numeric-3 area code.
+o LANG-1265: Build failures when building with Java 9 EA.
+o LANG-1314: javadoc creation broken with Java 8. Thanks to Allon Murienik.
+o LANG-1310: MethodUtils.invokeMethod throws ArrayStoreException if using
+             varargs arguments and smaller types than the method defines.
+             Thanks to Don Jeba.
+
+CHANGES
+=======
+
+o LANG-1110: Implement HashSetvBitSetTest using JMH.
+             Thanks to Bruno P. Kinoshita.
+o LANG-1290: Increase test coverage of org.apache.commons.lang3.ArrayUtils.
+             Thanks to Andrii Abramov.
+o LANG-1274: StrSubstitutor should state its thread safety.
+o LANG-1277: StringUtils#getLevenshteinDistance reduce memory consumption.
+             Thanks to yufcuy.
+o LANG-1279: Update Java requirement from Java 6 to 7.
+o LANG-1143: StringUtils should use toXxxxCase(int) rather than
+             toXxxxCase(char). Thanks to sebb.
+o LANG-1297: Add SystemUtils.getHostName() API.
+o LANG-1301: Moving apache-rat-plugin configuration into pluginManagement.
+             Thanks to Karl Heinz Marbaise.
+o LANG-1316: Deprecate classes/methods moved to commons-text.
+
+                        Release Notes for version 3.5
+
+
+HIGHLIGHTS
+==========
+
+Some of the highlights in this release include:
+
 o Added Java 9 detection to org.apache.commons.lang3.SystemUtils.
 o Support for shifting and swapping elements in
     org.apache.commons.lang3.ArrayUtils.


[42/50] [lang] [LANG-1331] ImmutablePair.nullPair() Update @SuppressWarnings.

Posted by br...@apache.org.
[LANG-1331] ImmutablePair.nullPair() Update @SuppressWarnings.

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

Branch: refs/heads/release
Commit: e1bc286245ce5f798b5312d65bba64c71921a3f4
Parents: 776b86e
Author: Gary Gregory <gg...@apache.org>
Authored: Sun May 14 20:36:31 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun May 14 20:36:31 2017 -0700

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e1bc2862/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
index 689ad24..85409fe 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
@@ -49,7 +49,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> {
      * @return an immutable pair of nulls. 
      * @since 3.6
      */
-    @SuppressWarnings("rawtypes")
+    @SuppressWarnings("unchecked")
     public static <L, R> ImmutablePair<L, R> nullPair() {
         return NULL;
     }


[46/50] [lang] Remove LANG-1291 from changes.xml since it has been reverted

Posted by br...@apache.org.
Remove LANG-1291 from changes.xml since it has been reverted


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

Branch: refs/heads/release
Commit: 05e18cc5c18b820b6f57c1cb823ad2c7fe513581
Parents: 796b051
Author: Benedikt Ritter <br...@apache.org>
Authored: Wed May 17 10:27:20 2017 -0400
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:27:20 2017 -0400

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


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/05e18cc5/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c106896..6a22895 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -73,7 +73,6 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1258" type="add" dev="pschumacher" due-to="IG, Grzegorz Rożniecki">Add ArrayUtils#toStringArray method</action>
     <action issue="LANG-1160" type="add" dev="kinow">StringUtils#abbreviate should support 'custom ellipses' parameter</action>
     <action issue="LANG-1293" type="add" dev="pschumacher" due-to="Pierre Templier, Martin Tarjanyi">Add StringUtils#isAllEmpty and #isAllBlank methods</action>
-    <action issue="LANG-1291" type="add" dev="ggregory">Provide annotations to document thread safety</action>
     <action issue="LANG-1290" type="update" dev="pschumacher" due-to="Andrii Abramov">Increase test coverage of org.apache.commons.lang3.ArrayUtils</action>
     <action issue="LANG-1274" type="update" dev="pschumacher">StrSubstitutor should state its thread safety</action>
     <action issue="LANG-1277" type="update" dev="pschumacher" due-to="yufcuy">StringUtils#getLevenshteinDistance reduce memory consumption</action>


[33/50] [lang] javadocs - fixed faulty samples of isNoneEmpty/isNoneBlank and added new ones to isAnyEmpty/isNoneEmpty/isAnyBlank/isNoneBlank for better understanding

Posted by br...@apache.org.
javadocs - fixed faulty samples of isNoneEmpty/isNoneBlank
and added new ones to isAnyEmpty/isNoneEmpty/isAnyBlank/isNoneBlank for better understanding


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

Branch: refs/heads/release
Commit: 6d74e8f83e96f536cbbad98cd4fe6fbd1cd67663
Parents: c8e648b
Author: Basha <ar...@paypalcorp.com>
Authored: Sun Apr 30 00:10:32 2017 +0530
Committer: Basha <ar...@paypalcorp.com>
Committed: Sun Apr 30 00:13:06 2017 +0530

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/StringUtils.java | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6d74e8f8/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index bd660bc..3385c64 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -240,6 +240,8 @@ public class StringUtils {
      * StringUtils.isAnyEmpty("  bob  ", null)  = true
      * StringUtils.isAnyEmpty(" ", "bar")       = false
      * StringUtils.isAnyEmpty("foo", "bar")     = false
+     * StringUtils.isAnyEmpty(new String[]{})   = false
+     * StringUtils.isAnyEmpty(new String[]{""}) = true
      * </pre>
      *
      * @param css  the CharSequences to check, may be null or empty
@@ -267,7 +269,8 @@ public class StringUtils {
      * StringUtils.isNoneEmpty("", "bar")        = false
      * StringUtils.isNoneEmpty("bob", "")        = false
      * StringUtils.isNoneEmpty("  bob  ", null)  = false
-     * StringUtils.isNoneEmpty(new String[] {})  = false
+     * StringUtils.isNoneEmpty(new String[] {})  = true
+     * StringUtils.isNoneEmpty(new String[]{""}) = false
      * StringUtils.isNoneEmpty(" ", "bar")       = true
      * StringUtils.isNoneEmpty("foo", "bar")     = true
      * </pre>
@@ -379,6 +382,7 @@ public class StringUtils {
      * StringUtils.isAnyBlank("  bob  ", null)  = true
      * StringUtils.isAnyBlank(" ", "bar")       = true
      * StringUtils.isAnyBlank(new String[] {})  = false
+     * StringUtils.isAnyBlank(new String[]{""}) = true
      * StringUtils.isAnyBlank("foo", "bar")     = false
      * </pre>
      *
@@ -411,7 +415,8 @@ public class StringUtils {
      * StringUtils.isNoneBlank("bob", "")        = false
      * StringUtils.isNoneBlank("  bob  ", null)  = false
      * StringUtils.isNoneBlank(" ", "bar")       = false
-     * StringUtils.isNoneBlank(new String[] {})  = false
+     * StringUtils.isNoneBlank(new String[] {})  = true
+     * StringUtils.isNoneBlank(new String[]{""}) = false
      * StringUtils.isNoneBlank("foo", "bar")     = true
      * </pre>
      *
@@ -1065,7 +1070,7 @@ public class StringUtils {
      * @see String#compareTo(String)
      * @param str1  the String to compare from
      * @param str2  the String to compare to
-     * @return &lt; 0, 0, &gt; 0, if {@code str1} is respectively less, equal ou greater than {@code str2}
+     * @return &lt; 0, 0, &gt; 0, if {@code str1} is respectively less, equal or greater than {@code str2}
      * @since 3.5
      */
     public static int compare(final String str1, final String str2) {


[19/50] [lang] LANG-1167: Add null filter to ReflectionToStringBuilder

Posted by br...@apache.org.
LANG-1167: Add null filter to ReflectionToStringBuilder

Fix/add since javadoc tags, fix checkstyle violations and do other small clean-ups.


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

Branch: refs/heads/release
Commit: 859224ffadb79147088840732236c1fad341d842
Parents: 0446364
Author: pascalschumacher <pa...@gmx.net>
Authored: Thu Apr 20 19:15:31 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Thu Apr 20 19:15:31 2017 +0200

----------------------------------------------------------------------
 .../lang3/builder/ReflectionToStringBuilder.java      | 14 ++++++++------
 ...eflectionToStringBuilderExcludeNullValuesTest.java | 11 +++++++----
 2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/859224ff/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 e315ed2..5e512d3 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -342,7 +342,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *            whether to include transient fields
      * @param outputStatics
      *            whether to include static fields
-     * @param excludeNulls
+     * @param excludeNullValues
      *            whether to exclude fields whose values are null
      * @param reflectUpToClass
      *            the superclass to reflect up to (inclusive), may be <code>null</code>
@@ -351,12 +351,12 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *             if the Object is <code>null</code>
      * 
      * @see ToStringExclude
-     * @since 2.1
+     * @since 3.6
      */
     public static <T> String toString(
             final T object, final ToStringStyle style, final boolean outputTransients,
-            final boolean outputStatics, boolean excludeNulls, final Class<? super T> reflectUpToClass) {
-        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNulls)
+            final boolean outputStatics, boolean excludeNullValues, final Class<? super T> reflectUpToClass) {
+        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNullValues)
                 .toString();
     }
 
@@ -565,7 +565,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *            whether to include static fields
      * @param excludeNullValues
      *            whether to exclude fields who value is null
-     * @since 2.1
+     * @since 3.6
      */
     public <T> ReflectionToStringBuilder(
             final T object, final ToStringStyle style, final StringBuffer buffer,
@@ -641,7 +641,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
                     // Warning: Field.get(Object) creates wrappers objects
                     // for primitive types.
                     final Object fieldValue = this.getValue(field);
-                    if(!excludeNullValues || fieldValue != null){
+                    if (!excludeNullValues || fieldValue != null) {
                         this.append(fieldName, fieldValue);
                     }
                 } catch (final IllegalAccessException ex) {
@@ -722,6 +722,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      * </p>
      *
      * @return Whether or not to append fields whose values are null.
+     * @since 3.6
      */
     public boolean isExcludeNullValues() {
         return this.excludeNullValues;
@@ -773,6 +774,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      *
      * @param excludeNullValues
      *            Whether or not to append fields whose values are null.
+     * @since 3.6
      */
     public void setExcludeNullValues(final boolean excludeNullValues) {
         this.excludeNullValues = excludeNullValues;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/859224ff/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
index 0a91609..dd94c51 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -17,17 +17,20 @@
 
 package org.apache.commons.lang3.builder;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
 public class ReflectionToStringBuilderExcludeNullValuesTest {
 
-    class TestFixture{
+    static class TestFixture {
+        @SuppressWarnings("unused")
         private Integer testIntegerField;
+        @SuppressWarnings("unused")
         private String testStringField;
-        
-        public TestFixture(Integer a, String b){
+
+        public TestFixture(Integer a, String b) {
             this.testIntegerField = a;
             this.testStringField = b;
         }


[21/50] [lang] LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods

Posted by br...@apache.org.
LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods

Add changes.xml entry and minimal clean-up.


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

Branch: refs/heads/release
Commit: 314b6b56bec4af56dba667d66a25c1613f4bc800
Parents: 46007c1
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Apr 21 10:45:03 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 21 10:45:03 2017 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  1 +
 .../commons/lang3/reflect/MethodUtils.java      | 60 ++++++++++----------
 2 files changed, 31 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/314b6b56/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e50441b..f4df009 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -85,6 +85,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1310" type="fix" dev="pschumacher" due-to="Don Jeba">MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines</action>
     <action issue="LANG-1313" type="add" dev="pschumacher" due-to="Tomschi">Add ArchUtils - An utility class for the "os.arch" system property</action>
     <action issue="LANG-1272" type="add" dev="ebourg">Add shuffle methods to ArrayUtils</action>
+    <action issue="LANG-1317" type="add" dev="pschumacher" due-to="Yasser Zamani">Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods</action>
   </release>
 
   <release version="3.5" date="2016-10-13" description="New features including Java 9 detection">

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/314b6b56/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 55b5cb1..107f317 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -866,9 +866,9 @@ public class MethodUtils {
      * @param annotationCls
      *            the {@link java.lang.annotation.Annotation} that must be present on a method to be matched
      * @param searchSupers
-     *            determines if also a lookup in the entire inheritance hierarchy of the given class should be performed
+     *            determines if a lookup in the entire inheritance hierarchy of the given class should be performed
      * @param ignoreAccess
-     *            determines if also non public methods should be considered
+     *            determines if non public methods should be considered
      * @return an array of Methods (possibly empty).
      * @throws IllegalArgumentException
      *            if the class or annotation are {@code null}
@@ -888,9 +888,9 @@ public class MethodUtils {
      * @param annotationCls
      *            the {@link Annotation} that must be present on a method to be matched
      * @param searchSupers
-     *            determines if also a lookup in the entire inheritance hierarchy of the given class should be performed
+     *            determines if a lookup in the entire inheritance hierarchy of the given class should be performed
      * @param ignoreAccess
-     *            determines if also non public methods should be considered
+     *            determines if non public methods should be considered
      * @return a list of Methods (possibly empty).
      * @throws IllegalArgumentException
      *            if the class or annotation are {@code null}
@@ -904,7 +904,7 @@ public class MethodUtils {
         Validate.isTrue(annotationCls != null, "The annotation class must not be null");
         List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
                 : new ArrayList<Class<?>>());
-        classes.add(0, cls);
+        classes.add(cls);
         final List<Method> annotatedMethods = new ArrayList<>();
         for (Class<?> acls : classes) {
             final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods());
@@ -918,12 +918,12 @@ public class MethodUtils {
     }
 
     /**
-     * <p>Gets the annotation object that is present on the given method or any equivalent method in
-     * super classes and interfaces, with the given annotation type. Returns null if the annotation
-     * type was not present on any of them.</p>
+     * <p>Gets the annotation object with the given annotation type that is present on the given method
+     * or optionally on any equivalent method in super classes and interfaces. Returns null if the annotation
+     * type was not present.</p>
      *
      * <p>Stops searching for an annotation once the first annotation of the specified type has been
-     * found. i.e, additional annotations of the specified type will be silently ignored.</p>
+     * found. Additional annotations of the specified type will be silently ignored.</p>
      * @param <A>
      *            the annotation type
      * @param method
@@ -931,7 +931,8 @@ public class MethodUtils {
      * @param annotationCls
      *            the {@link Annotation} to check if is present on the method
      * @param searchSupers
-     *            determines if lookup in the entire inheritance hierarchy of the given class if was not directly present
+     *            determines if a lookup in the entire inheritance hierarchy of the given class is performed
+     *            if the annotation was not directly present
      * @param ignoreAccess
      *            determines if underlying method has to be accessible
      * @return the first matching annotation, or {@code null} if not found
@@ -944,13 +945,13 @@ public class MethodUtils {
 
         Validate.isTrue(method != null, "The method must not be null");
         Validate.isTrue(annotationCls != null, "The annotation class must not be null");
-        if(!ignoreAccess && !MemberUtils.isAccessible(method)) {
+        if (!ignoreAccess && !MemberUtils.isAccessible(method)) {
             return null;
         }
 
         A annotation = method.getAnnotation(annotationCls);
 
-        if(annotation == null && searchSupers) {
+        if (annotation == null && searchSupers) {
             Class<?> mcls = method.getDeclaringClass();
             List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls);
             for (Class<?> acls : classes) {
@@ -959,7 +960,7 @@ public class MethodUtils {
                     equivalentMethod = (ignoreAccess ? acls.getDeclaredMethod(method.getName(), method.getParameterTypes())
                             : acls.getMethod(method.getName(), method.getParameterTypes()));
                 } catch (NoSuchMethodException e) {
-                    // If not found, just keep on search
+                    // if not found, just keep searching
                     continue;
                 }
                 annotation = equivalentMethod.getAnnotation(annotationCls);
@@ -981,34 +982,33 @@ public class MethodUtils {
      * @return the combined {@code List} of superclasses and interfaces in order
      * going up from this one
      *  {@code null} if null input
-     * @since 3.6
      */
     private static List<Class<?>> getAllSuperclassesAndInterfaces(final Class<?> cls) {
         if (cls == null) {
             return null;
         }
 
-        final List<Class<?>> classes = new ArrayList<>();
+        final List<Class<?>> allSuperClassesAndInterfaces = new ArrayList<>();
         List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(cls);
-        int sci = 0;
+        int superClassIndex = 0;
         List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(cls);
-        int ifi = 0;
-        while (ifi < allInterfaces.size() ||
-                sci < allSuperclasses.size()) {
+        int interfaceIndex = 0;
+        while (interfaceIndex < allInterfaces.size() ||
+                superClassIndex < allSuperclasses.size()) {
             Class<?> acls;
-            if (ifi >= allInterfaces.size()) {
-                acls = allSuperclasses.get(sci++);
-            } else if (sci >= allSuperclasses.size()) {
-                acls = allInterfaces.get(ifi++);
-            } else if (ifi < sci) {
-                acls = allInterfaces.get(ifi++);
-            } else if (sci < ifi) {
-                acls = allSuperclasses.get(sci++);
+            if (interfaceIndex >= allInterfaces.size()) {
+                acls = allSuperclasses.get(superClassIndex++);
+            } else if (superClassIndex >= allSuperclasses.size()) {
+                acls = allInterfaces.get(interfaceIndex++);
+            } else if (interfaceIndex < superClassIndex) {
+                acls = allInterfaces.get(interfaceIndex++);
+            } else if (superClassIndex < interfaceIndex) {
+                acls = allSuperclasses.get(superClassIndex++);
             } else {
-                acls = allInterfaces.get(ifi++);
+                acls = allInterfaces.get(interfaceIndex++);
             }
-            classes.add(acls);
+            allSuperClassesAndInterfaces.add(acls);
         }
-        return classes;
+        return allSuperClassesAndInterfaces;
     }
 }


[22/50] [lang] LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods

Posted by br...@apache.org.
LANG-1317: Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods

fix bug introduced by last commit


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

Branch: refs/heads/release
Commit: 8cafd87c83f4197f7e8d14de8cba453c844266c0
Parents: 314b6b5
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Apr 21 10:53:17 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 21 10:53:17 2017 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8cafd87c/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 107f317..2855410 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -904,7 +904,7 @@ public class MethodUtils {
         Validate.isTrue(annotationCls != null, "The annotation class must not be null");
         List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
                 : new ArrayList<Class<?>>());
-        classes.add(cls);
+        classes.add(0, cls);
         final List<Method> annotatedMethods = new ArrayList<>();
         for (Class<?> acls : classes) {
             final Method[] methods = (ignoreAccess ? acls.getDeclaredMethods() : acls.getMethods());


[11/50] [lang] FindBugs exclude filter for StringUtils

Posted by br...@apache.org.
FindBugs exclude filter for StringUtils

Exclude ES_COMPARING_PARAMETER_STRING_WITH_EQ FindBugs warnings from
StringUtils methods compare(String, String, boolean) and
compareIgnoreCase(String, String, boolean).

The usages of the == operator seem to be intentional optimizations
similar to the usage in indexOfDifference. If this reasoning is ever
overruled, this suppression should be removed.


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

Branch: refs/heads/release
Commit: 3304965840c139dae7b8c01e1779a806641a0159
Parents: 5a52446
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 11:44:39 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/33049658/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index def3ec8..f7623df 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -58,7 +58,11 @@
   <!-- Reason: Optimization to use == -->
   <Match>
     <Class name="org.apache.commons.lang3.StringUtils" />
-    <Method name="indexOfDifference"/>
+    <Or>
+      <Method name="indexOfDifference"/>
+      <Method name="compare" params="java.lang.String,java.lang.String,boolean"/>
+      <Method name="compareIgnoreCase" params="java.lang.String,java.lang.String,boolean"/>
+    </Or>
     <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
   </Match>
 


[25/50] [lang] LANG-1256: Add JMH maven dependencies. (closes #182)

Posted by br...@apache.org.
LANG-1256: Add JMH maven dependencies. (closes #182)

In order to provide patch for LANG-1110, required dependency on JMH lib.
Current commit add benchmark profile and ability to run JMH based benchmark by
executing "mvn test -P benchmark" command, moreover it's also possible to
specify exact benchmark name by running "mvn test -P benchmark
-Dbenchmark=benchmark.full.class.name".


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

Branch: refs/heads/release
Commit: 111fd3f6eef8e7d1641a42ce0cc56b92f2d75f4a
Parents: a060733
Author: Artem Barger <ar...@bargr.net>
Authored: Sat Aug 13 03:33:08 2016 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 28 17:30:46 2017 +0200

----------------------------------------------------------------------
 pom.xml | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/111fd3f6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bca6df4..9b22eb3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -535,6 +535,21 @@
       <version>3.4</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.openjdk.jmh</groupId>
+      <artifactId>jmh-core</artifactId>
+      <version>${jmh.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.openjdk.jmh</groupId>
+      <artifactId>jmh-generator-annprocess</artifactId>
+      <version>${jmh.version}</version>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <distributionManagement>
@@ -580,6 +595,10 @@
     <!-- Override clirr version to be able to build the site on Java 8 -->
     <commons.clirr.version>2.8</commons.clirr.version>
     <checkstyle.plugin.version>2.17</checkstyle.plugin.version>
+
+    <!-- JMH Benchmark related properties, version, target compiler and name of the benchmarking uber jar. -->
+    <jmh.version>1.17.4</jmh.version>
+    <uberjar.name>benchmarks</uberjar.name>
   </properties>
 
 
@@ -846,6 +865,55 @@
         <argLine>-Xmx512m --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
       </properties>
     </profile>
-  </profiles>
+
+    <profile>
+      <id>benchmark</id>
+      <properties>
+        <skipTests>true</skipTests>
+        <benchmark>org.apache</benchmark>
+      </properties>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <version>3.1</version>
+            <configuration>
+              <compilerVersion>${maven.compiler.target}</compilerVersion>
+              <source>${maven.compiler.target}</source>
+              <target>${maven.compiler.target}</target>
+            </configuration>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>benchmark</id>
+                <phase>test</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <classpathScope>test</classpathScope>
+                  <executable>java</executable>
+                  <arguments>
+                    <argument>-classpath</argument>
+                    <classpath/>
+                    <argument>org.openjdk.jmh.Main</argument>
+                    <argument>-rf</argument>
+                    <argument>json</argument>
+                    <argument>-rff</argument>
+                    <argument>target/jmh-result.${benchmark}.json</argument>
+                    <argument>${benchmark}</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>  </profiles>
 
 </project>


[38/50] [lang] Merge branch 'pr/266'

Posted by br...@apache.org.
Merge branch 'pr/266'

This closes #266

Thanks!


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

Branch: refs/heads/release
Commit: 7ddfc8ae1c4d712b0e52d2595b36743700940873
Parents: 88da5f4 6d74e8f
Author: Bruno P. Kinoshita <ki...@apache.org>
Authored: Mon May 1 21:54:51 2017 +1200
Committer: Bruno P. Kinoshita <ki...@apache.org>
Committed: Mon May 1 21:54:51 2017 +1200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/StringUtils.java | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/7ddfc8ae/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------


[36/50] [lang] Merge branch 'pr/265'

Posted by br...@apache.org.
Merge branch 'pr/265'

This closes #265

Thanks


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

Branch: refs/heads/release
Commit: af323712479ba1e2a5b8e519030d021915228c48
Parents: 610caab 9766e22
Author: Bruno P. Kinoshita <ki...@apache.org>
Authored: Mon May 1 21:45:25 2017 +1200
Committer: Bruno P. Kinoshita <ki...@apache.org>
Committed: Mon May 1 21:45:25 2017 +1200

----------------------------------------------------------------------
 .../lang3/builder/ToStringBuilderTest.java      | 239 +++++++++++++++++++
 1 file changed, 239 insertions(+)
----------------------------------------------------------------------



[09/50] [lang] Exclude SF_SWITCH_FALLTHROUGH on FastDatePrinter

Posted by br...@apache.org.
Exclude SF_SWITCH_FALLTHROUGH on FastDatePrinter

FastDatePrinter#appendFullDigits uses a switch statement that
intentionally falls through the cases.
This patch adds a FindBugs suppression for it.


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

Branch: refs/heads/release
Commit: 4d343ccc1181e306f8bb9431087ebb5e58b0c3c9
Parents: c40dcf6
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:38:54 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/4d343ccc/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index 772052a..edc6ead 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -150,6 +150,13 @@
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
 
+  <!-- Reason: The fallthrough on the swich stateme is intentional -->
+  <Match>
+    <Class name="org.apache.commons.lang3.time.FastDatePrinter"/>
+    <Method name="appendFullDigits" params="java.lang.Appendable, int, int"/>
+    <Bug pattern="SF_SWITCH_FALLTHROUGH" />
+  </Match>
+
   <!-- Reason: Internal class that is used only as a key for an internal FormatCache. For this reason we can
    be sure, that equals will never be called with null or types other than MultipartKey.
   -->


[45/50] [lang] Remove annotations for documenting concurrency behavior.

Posted by br...@apache.org.
Remove annotations for documenting concurrency behavior.

As discussed on the ML, we need more time to figure out the design of
this annotations. So I'm removing them in order to get the next release
out of the door.


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

Branch: refs/heads/release
Commit: 796b051f28ca96f1dbbd5dfe4b5cae5579d0d14e
Parents: 5a87fa1
Author: Benedikt Ritter <br...@apache.org>
Authored: Wed May 17 10:21:41 2017 -0400
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:21:41 2017 -0400

----------------------------------------------------------------------
 .../lang3/concurrent/annotation/Contract.java   | 50 ---------------
 .../lang3/concurrent/annotation/GuardedBy.java  | 39 ------------
 .../lang3/concurrent/annotation/Immutable.java  | 33 ----------
 .../concurrent/annotation/NotThreadSafe.java    | 35 -----------
 .../lang3/concurrent/annotation/ThreadSafe.java | 35 -----------
 .../annotation/ThreadingBehavior.java           | 66 --------------------
 .../concurrent/annotation/package-info.java     | 22 -------
 .../annotation/AnnotationTestUtils.java         | 50 ---------------
 .../concurrent/annotation/ContractTest.java     | 38 -----------
 .../annotation/ContractTestFixture.java         | 25 --------
 .../concurrent/annotation/GuardedByTest.java    | 65 -------------------
 .../annotation/GuardedByTestFixture.java        | 32 ----------
 .../concurrent/annotation/ImmutableTest.java    | 38 -----------
 .../annotation/ImmutableTestFixture.java        | 25 --------
 .../annotation/NotThreadSafeTest.java           | 39 ------------
 .../annotation/NotThreadSafeTestFixture.java    | 25 --------
 .../concurrent/annotation/ThreadSafeTest.java   | 39 ------------
 .../annotation/ThreadSafeTestFixture.java       | 25 --------
 18 files changed, 681 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java
deleted file mode 100644
index e34bb95..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/Contract.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-package org.apache.commons.lang3.concurrent.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation defines behavioral contract enforced at runtime by instances of annotated classes.
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface Contract {
-
-    /**
-     * Defines behavioral contract enforced at runtime by instances of annotated classes.
-     * 
-     * @return The behavioral contract enforced at runtime by instances of annotated classes.
-     */
-    ThreadingBehavior threading() default ThreadingBehavior.UNSAFE;
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/GuardedBy.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/GuardedBy.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/GuardedBy.java
deleted file mode 100644
index abd2416..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/GuardedBy.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes the lock which guards a field or method.
- */
-@Documented
-@Target({ ElementType.FIELD, ElementType.METHOD })
-@Retention(RetentionPolicy.CLASS)
-public @interface GuardedBy {
-
-    /**
-     * Gets the lock which guards a field or method.
-     * 
-     * @return the lock which guards a field or method.
-     */
-    String value();
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/Immutable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/Immutable.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/Immutable.java
deleted file mode 100644
index 0de343c..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/Immutable.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes a type as immutable.
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface Immutable {
-    // marker annotation, empty body
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafe.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafe.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafe.java
deleted file mode 100644
index 78b2b03..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafe.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes this type as not thread-safe.
- * 
- * @see ThreadSafe
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface NotThreadSafe {
-    // marker annotation, empty body
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafe.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafe.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafe.java
deleted file mode 100644
index cef8c64..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafe.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Describes this type as thread-safe.
- * 
- * @see NotThreadSafe
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface ThreadSafe {
-    // marker annotation, empty body
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java
deleted file mode 100644
index e03b164..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/ThreadingBehavior.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-package org.apache.commons.lang3.concurrent.annotation;
-
-/**
- * Defines types of threading behavior enforced at runtime.
- */
-public enum ThreadingBehavior {
-
-    /**
-     * Instances of classes with the given contract are expected to be fully immutable and thread-safe.
-     */
-    IMMUTABLE,
-
-    /**
-     * Instances of classes with the given contract are expected to be immutable if their dependencies injected at
-     * construction time are immutable and are expected to be thread-safe if their dependencies are thread-safe.
-     */
-    IMMUTABLE_CONDITIONAL,
-
-    /**
-     * Instances of classes with the given contract are expected to maintain no state and to be thread-safe.
-     */
-    STATELESS,
-
-    /**
-     * Instances of classes with the given contract are expected to be fully thread-safe.
-     */
-    SAFE,
-
-    /**
-     * Instances of classes with the given contract are expected to be thread-safe if their dependencies injected at
-     * construction time are thread-safe.
-     */
-    SAFE_CONDITIONAL,
-
-    /**
-     * Instances of classes with the given contract are expected to be non thread-safe.
-     */
-    UNSAFE
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/main/java/org/apache/commons/lang3/concurrent/annotation/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/annotation/package-info.java b/src/main/java/org/apache/commons/lang3/concurrent/annotation/package-info.java
deleted file mode 100644
index 3f29ebf..0000000
--- a/src/main/java/org/apache/commons/lang3/concurrent/annotation/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-/**
- * <p>Provides annotations to document classes' thread safety</p>
- *
- * @since 3.6
- */
-package org.apache.commons.lang3.concurrent.annotation;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/AnnotationTestUtils.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/AnnotationTestUtils.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/AnnotationTestUtils.java
deleted file mode 100644
index ea4bb3e..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/AnnotationTestUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-import org.apache.bcel.Repository;
-import org.apache.bcel.classfile.AnnotationEntry;
-import org.apache.bcel.classfile.ElementValuePair;
-import org.apache.bcel.classfile.JavaClass;
-import org.apache.commons.lang3.reflect.MethodUtils;
-import org.junit.Assert;
-
-class AnnotationTestUtils {
-
-    public static void testClassAnnotationInClassFile(final String className, final String annotationType) throws Exception {
-        final JavaClass clazz = Repository.lookupClass(className);
-        final AnnotationEntry[] annotationEntries = clazz.getAnnotationEntries();
-        Assert.assertNotNull(annotationEntries);
-        Assert.assertEquals(1, annotationEntries.length);
-        final AnnotationEntry annotationEntry = annotationEntries[0];
-        Assert.assertEquals(annotationType, annotationEntry .getAnnotationType());
-        final ElementValuePair[] elementValuePairs = annotationEntry.getElementValuePairs();
-        Assert.assertNotNull(elementValuePairs);
-        Assert.assertEquals(0, elementValuePairs.length);
-    }
-
-    public static void testMethodAnnotationNotRetainedAtRuntime(final Class<?> cls,
-            final Class<? extends Annotation> annotationCls) {
-        final Method[] methods = MethodUtils.getMethodsWithAnnotation(cls, annotationCls);
-        Assert.assertNotNull(methods);
-        Assert.assertEquals(0, methods.length);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java
deleted file mode 100644
index affa786..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import org.junit.Test;
-
-/**
- * Tests {@link Contract}.
- */
-public class ContractTest {
-
-    @Test
-    public void testClassAnnotationInClassFile() throws Exception {
-        AnnotationTestUtils.testClassAnnotationInClassFile(
-                "org.apache.commons.lang3.concurrent.annotation.ContractTestFixture",
-                "Lorg/apache/commons/lang3/concurrent/annotation/Contract;");
-    }
-
-    @Test
-    public void testMethodAnnotationNotRetainedAtRuntime() {
-        AnnotationTestUtils.testMethodAnnotationNotRetainedAtRuntime(ContractTestFixture.class, Contract.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java
deleted file mode 100644
index 6d254b1..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-/**
- * Tests {@link Immutable}.
- */
-@Contract()
-public class ContractTestFixture {
-    // empty
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTest.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTest.java
deleted file mode 100644
index ecdd4ad..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import org.apache.bcel.Repository;
-import org.apache.bcel.classfile.AnnotationEntry;
-import org.apache.bcel.classfile.ElementValue;
-import org.apache.bcel.classfile.ElementValuePair;
-import org.apache.bcel.classfile.JavaClass;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests {@link GuardedBy}.
- */
-public class GuardedByTest {
-
-    private org.apache.bcel.classfile.Method getBcelMethod(final JavaClass clazz, final String name) {
-        for (final org.apache.bcel.classfile.Method method : clazz.getMethods()) {
-            if (method.getName().equals(name)) {
-                return method;
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void testMethodAnnotationInClassFile() throws Exception {
-        final JavaClass clazz = Repository.lookupClass("org.apache.commons.lang3.concurrent.annotation.GuardedByTestFixture");
-        final org.apache.bcel.classfile.Method method = getBcelMethod(clazz, "foo");
-        Assert.assertNotNull(method);
-        final AnnotationEntry[] annotationEntries = method.getAnnotationEntries();
-        Assert.assertNotNull(annotationEntries);
-        Assert.assertEquals(1, annotationEntries.length);
-        final AnnotationEntry annotationEntry = annotationEntries[0];
-        Assert.assertEquals("Lorg/apache/commons/lang3/concurrent/annotation/GuardedBy;", annotationEntry .getAnnotationType());
-        final ElementValuePair[] elementValuePairs = annotationEntry.getElementValuePairs();
-        Assert.assertNotNull(elementValuePairs);
-        Assert.assertEquals(1, elementValuePairs.length);
-        final ElementValuePair elementValuePair = elementValuePairs[0];
-        final ElementValue value = elementValuePair.getValue();
-        Assert.assertNotNull(value);
-        Assert.assertEquals("bar", value.toString());
-    }
-
-    @Test
-    public void testMethodAnnotationNotRetainedAtRuntime() {
-        AnnotationTestUtils.testMethodAnnotationNotRetainedAtRuntime(GuardedByTestFixture.class, GuardedBy.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTestFixture.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTestFixture.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTestFixture.java
deleted file mode 100644
index 89bd3f7..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/GuardedByTestFixture.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-/**
- * Tests {@link GuardedBy}.
- */
-public class GuardedByTestFixture {
-
-    @GuardedBy("ping")
-    private Object pong;
-    
-    @GuardedBy("bar")
-    public void foo() {
-        // empty
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTest.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTest.java
deleted file mode 100644
index deef67d..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import org.junit.Test;
-
-/**
- * Tests {@link GuardedBy}.
- */
-public class ImmutableTest {
-
-    @Test
-    public void testClassAnnotationInClassFile() throws Exception {
-        AnnotationTestUtils.testClassAnnotationInClassFile(
-                "org.apache.commons.lang3.concurrent.annotation.ImmutableTestFixture",
-                "Lorg/apache/commons/lang3/concurrent/annotation/Immutable;");
-    }
-
-    @Test
-    public void testMethodAnnotationNotRetainedAtRuntime() {
-        AnnotationTestUtils.testMethodAnnotationNotRetainedAtRuntime(ImmutableTestFixture.class, Immutable.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTestFixture.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTestFixture.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTestFixture.java
deleted file mode 100644
index c14debf..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ImmutableTestFixture.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-/**
- * Tests {@link Immutable}.
- */
-@Immutable
-public class ImmutableTestFixture {
-    // empty
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTest.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTest.java
deleted file mode 100644
index 616152c..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import org.junit.Test;
-
-/**
- * Tests {@link NotThreadSafe}.
- */
-public class NotThreadSafeTest {
-
-    @Test
-    public void testClassAnnotationInClassFile() throws Exception {
-        AnnotationTestUtils.testClassAnnotationInClassFile(
-                "org.apache.commons.lang3.concurrent.annotation.NotThreadSafeTestFixture",
-                "Lorg/apache/commons/lang3/concurrent/annotation/NotThreadSafe;");
-    }
-
-    @Test
-    public void testMethodAnnotationNotRetainedAtRuntime() {
-        AnnotationTestUtils.testMethodAnnotationNotRetainedAtRuntime(NotThreadSafeTestFixture.class,
-                NotThreadSafe.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTestFixture.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTestFixture.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTestFixture.java
deleted file mode 100644
index a11ac3f..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/NotThreadSafeTestFixture.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-/**
- * Tests {@link NotThreadSafe}.
- */
-@NotThreadSafe
-public class NotThreadSafeTestFixture {
-    // empty
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTest.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTest.java
deleted file mode 100644
index 8d387fb..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-import org.junit.Test;
-
-/**
- * Tests {@link ThreadSafe}.
- */
-public class ThreadSafeTest {
-
-    @Test
-    public void testClassAnnotationInClassFile() throws Exception {
-        AnnotationTestUtils.testClassAnnotationInClassFile(
-                "org.apache.commons.lang3.concurrent.annotation.ThreadSafeTestFixture",
-                "Lorg/apache/commons/lang3/concurrent/annotation/ThreadSafe;");
-    }
-
-    @Test
-    public void testMethodAnnotationNotRetainedAtRuntime() {
-        AnnotationTestUtils.testMethodAnnotationNotRetainedAtRuntime(ThreadSafeTestFixture.class,
-                ThreadSafe.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/796b051f/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTestFixture.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTestFixture.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTestFixture.java
deleted file mode 100644
index 81ef775..0000000
--- a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ThreadSafeTestFixture.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.lang3.concurrent.annotation;
-
-/**
- * Tests {@link ThreadSafe}.
- */
-@ThreadSafe
-public class ThreadSafeTestFixture {
-    // empty
-}


[07/50] [lang] Fixed the indentation in ArrayUtilsTest

Posted by br...@apache.org.
Fixed the indentation in ArrayUtilsTest


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

Branch: refs/heads/release
Commit: 5a52446090a67b9b04b67a0b7aec94e73bd21930
Parents: a91f76d
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Tue Apr 18 22:52:21 2017 +0200
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Tue Apr 18 22:52:21 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/lang3/ArrayUtilsTest.java    | 278 +++++++++----------
 1 file changed, 139 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/5a524460/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index 63da4e4..9388e24 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -4345,39 +4345,39 @@ public class ArrayUtilsTest  {
 
     //  testToPrimitive/Object for int
     //  -----------------------------------------------------------------------
-     @Test
-     public void testToPrimitive_int() {
-         final Integer[] b = null;
-         assertEquals(null, ArrayUtils.toPrimitive(b));
-         assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0]));
-         assertTrue(Arrays.equals(
-             new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), 
-                 Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)}))
-         );
-
-         try {
-             ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null});
-             fail();
-         } catch (final NullPointerException ex) {}
-     }
-
-     @Test
-     public void testToPrimitive_int_int() {
-         final Long[] l = null;
-         assertEquals(null, ArrayUtils.toPrimitive(l, Integer.MIN_VALUE));
-         assertSame(ArrayUtils.EMPTY_INT_ARRAY, 
-         ArrayUtils.toPrimitive(new Integer[0], 1));
-         assertTrue(Arrays.equals(
-             new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), 
-                 Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)},1)));
-         assertTrue(Arrays.equals(
-             new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), 
-                 null, Integer.valueOf(9999999)}, Integer.MAX_VALUE))
-         );
-     }
+    @Test
+    public void testToPrimitive_int() {
+        final Integer[] b = null;
+        assertEquals(null, ArrayUtils.toPrimitive(b));
+        assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0]));
+        assertTrue(Arrays.equals(
+            new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), 
+                Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)}))
+        );
+
+        try {
+            ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null});
+            fail();
+        } catch (final NullPointerException ex) {}
+    }
+
+    @Test
+    public void testToPrimitive_int_int() {
+        final Long[] l = null;
+        assertEquals(null, ArrayUtils.toPrimitive(l, Integer.MIN_VALUE));
+        assertSame(ArrayUtils.EMPTY_INT_ARRAY, 
+        ArrayUtils.toPrimitive(new Integer[0], 1));
+        assertTrue(Arrays.equals(
+            new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), 
+                Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)},1)));
+        assertTrue(Arrays.equals(
+            new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), 
+                null, Integer.valueOf(9999999)}, Integer.MAX_VALUE))
+        );
+    }
      
     @Test
     public void testToPrimitive_intNull() {
@@ -4406,45 +4406,45 @@ public class ArrayUtilsTest  {
 
     //  testToPrimitive/Object for long
     //  -----------------------------------------------------------------------
-     @Test
-     public void testToPrimitive_long() {
-         final Long[] b = null;
-         assertEquals(null, ArrayUtils.toPrimitive(b));
-         
-         assertSame(ArrayUtils.EMPTY_LONG_ARRAY, 
-            ArrayUtils.toPrimitive(new Long[0]));
-         
-         assertTrue(Arrays.equals(
-             new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), 
-                 Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)}))
-         );
-
-         try {
-             ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), null});
-             fail();
-         } catch (final NullPointerException ex) {}
-     }
-
-     @Test
-     public void testToPrimitive_long_long() {
-         final Long[] l = null;
-         assertEquals(null, ArrayUtils.toPrimitive(l, Long.MIN_VALUE));
+    @Test
+    public void testToPrimitive_long() {
+        final Long[] b = null;
+        assertEquals(null, ArrayUtils.toPrimitive(b));
+        
+        assertSame(ArrayUtils.EMPTY_LONG_ARRAY, 
+           ArrayUtils.toPrimitive(new Long[0]));
+        
+        assertTrue(Arrays.equals(
+            new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), 
+                Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)}))
+        );
+
+        try {
+            ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), null});
+            fail();
+        } catch (final NullPointerException ex) {}
+    }
+
+    @Test
+    public void testToPrimitive_long_long() {
+        final Long[] l = null;
+        assertEquals(null, ArrayUtils.toPrimitive(l, Long.MIN_VALUE));
          
-         assertSame(ArrayUtils.EMPTY_LONG_ARRAY, 
-         ArrayUtils.toPrimitive(new Long[0], 1));
+        assertSame(ArrayUtils.EMPTY_LONG_ARRAY, 
+        ArrayUtils.toPrimitive(new Long[0], 1));
          
-         assertTrue(Arrays.equals(
-             new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), 
-                 Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)},1)));
+        assertTrue(Arrays.equals(
+            new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), 
+                Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)},1)));
          
-         assertTrue(Arrays.equals(
-             new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), 
-                 null, Long.valueOf(9999999)}, Long.MAX_VALUE))
-         );
-     }
+        assertTrue(Arrays.equals(
+            new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), 
+                null, Long.valueOf(9999999)}, Long.MAX_VALUE))
+        );
+    }
      
     @Test
     public void testToObject_long() {
@@ -4467,45 +4467,45 @@ public class ArrayUtilsTest  {
 
     //  testToPrimitive/Object for float
     //  -----------------------------------------------------------------------
-     @Test
-     public void testToPrimitive_float() {
-         final Float[] b = null;
-         assertEquals(null, ArrayUtils.toPrimitive(b));
+    @Test
+    public void testToPrimitive_float() {
+        final Float[] b = null;
+        assertEquals(null, ArrayUtils.toPrimitive(b));
          
-         assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, 
-            ArrayUtils.toPrimitive(new Float[0]));
+        assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, 
+           ArrayUtils.toPrimitive(new Float[0]));
          
-         assertTrue(Arrays.equals(
-             new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
-                 Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)}))
-         );
-
-         try {
-             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
-             fail();
-         } catch (final NullPointerException ex) {}
-     }
-
-     @Test
-     public void testToPrimitive_float_float() {
-         final Float[] l = null;
-         assertEquals(null, ArrayUtils.toPrimitive(l, Float.MIN_VALUE));
+        assertTrue(Arrays.equals(
+            new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
+                Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)}))
+        );
+
+        try {
+            ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
+            fail();
+        } catch (final NullPointerException ex) {}
+    }
+
+    @Test
+    public void testToPrimitive_float_float() {
+        final Float[] l = null;
+        assertEquals(null, ArrayUtils.toPrimitive(l, Float.MIN_VALUE));
          
-         assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, 
-         ArrayUtils.toPrimitive(new Float[0], 1));
+        assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, 
+        ArrayUtils.toPrimitive(new Float[0], 1));
          
-         assertTrue(Arrays.equals(
-             new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
-                 Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)},1)));
+        assertTrue(Arrays.equals(
+            new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
+                Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)},1)));
          
-         assertTrue(Arrays.equals(
-             new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
-                 null, Float.valueOf(9999999)}, Float.MAX_VALUE))
-         );
-     }
+        assertTrue(Arrays.equals(
+            new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), 
+                null, Float.valueOf(9999999)}, Float.MAX_VALUE))
+        );
+    }
      
     @Test
     public void testToObject_float() {
@@ -4528,45 +4528,45 @@ public class ArrayUtilsTest  {
 
     //  testToPrimitive/Object for double
     //  -----------------------------------------------------------------------
-     @Test
-     public void testToPrimitive_double() {
-         final Double[] b = null;
-         assertEquals(null, ArrayUtils.toPrimitive(b));
+    @Test
+    public void testToPrimitive_double() {
+        final Double[] b = null;
+        assertEquals(null, ArrayUtils.toPrimitive(b));
          
-         assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, 
-            ArrayUtils.toPrimitive(new Double[0]));
+        assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, 
+           ArrayUtils.toPrimitive(new Double[0]));
          
-         assertTrue(Arrays.equals(
-             new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
-                 Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)}))
-         );
-
-         try {
-             ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
-             fail();
-         } catch (final NullPointerException ex) {}
-     }
-
-     @Test
-     public void testToPrimitive_double_double() {
-         final Double[] l = null;
-         assertEquals(null, ArrayUtils.toPrimitive(l, Double.MIN_VALUE));
+        assertTrue(Arrays.equals(
+            new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
+                Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)}))
+        );
+
+        try {
+            ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null});
+            fail();
+        } catch (final NullPointerException ex) {}
+    }
+
+    @Test
+    public void testToPrimitive_double_double() {
+        final Double[] l = null;
+        assertEquals(null, ArrayUtils.toPrimitive(l, Double.MIN_VALUE));
          
-         assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, 
-         ArrayUtils.toPrimitive(new Double[0], 1));
+        assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, 
+        ArrayUtils.toPrimitive(new Double[0], 1));
          
-         assertTrue(Arrays.equals(
-             new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
-                 Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)},1)));
+        assertTrue(Arrays.equals(
+            new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
+                Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)},1)));
          
-         assertTrue(Arrays.equals(
-             new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
-             ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
-                 null, Double.valueOf(9999999)}, Double.MAX_VALUE))
-         );
-     }
+        assertTrue(Arrays.equals(
+            new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999},
+            ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), 
+                null, Double.valueOf(9999999)}, Double.MAX_VALUE))
+        );
+    }
      
     @Test
     public void testToObject_double() {
@@ -4661,7 +4661,7 @@ public class ArrayUtilsTest  {
         assertFalse(ArrayUtils.isEmpty(notEmptyBooleanArray));
     }
     
-   /**
+    /**
      * Test for {@link ArrayUtils#isNotEmpty(java.lang.Object[])}.
      */
     @Test
@@ -4673,7 +4673,7 @@ public class ArrayUtilsTest  {
         assertTrue(ArrayUtils.isNotEmpty(notEmptyArray));
     }
 
-   /**
+    /**
      * Tests for {@link ArrayUtils#isNotEmpty(long[])},
      * {@link ArrayUtils#isNotEmpty(int[])},
      * {@link ArrayUtils#isNotEmpty(short[])},


[13/50] [lang] Add FindBugs to Travis CI (closes #262)

Posted by br...@apache.org.
Add FindBugs to Travis CI (closes #262)

This patch copies the FindBugs configuration in pom.xml from the
reporting section to the build section so findbugs can be used as part
of the build process (by using the maven goal findbugs:check).

It then adds this goal to the Travis CI build so that FindBugs
becomes part of the CI, and new patches would be prevented from
introducing new FindBugs errors.


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

Branch: refs/heads/release
Commit: 9ceaaeb6566c78b25da0ae8181964b13f09204a8
Parents: 9f7d03f
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:49:24 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:25:04 2017 +0200

----------------------------------------------------------------------
 .travis.yml | 2 +-
 pom.xml     | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9ceaaeb6/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index e81e8cd..f0a6c49 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ jdk:
   - oraclejdk8
 
 script:
-  - mvn test apache-rat:check clirr:check checkstyle:check javadoc:javadoc -B
+  - mvn test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc -B
 
 after_success:
   - mvn clean cobertura:cobertura coveralls:report

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9ceaaeb6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8bea60c..bca6df4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -660,6 +660,15 @@
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <!-- Use version from parent pom as that is adjusted according to the Java version used to run Maven -->
+        <version>${commons.findbugs.version}</version>
+        <configuration>
+          <excludeFilterFile>${basedir}/findbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
     </plugins>
 
   </build>


[17/50] [lang] Merge branch 'LANG-1167' of https://github.com/MarkDacek/commons-lang

Posted by br...@apache.org.
Merge branch 'LANG-1167' of https://github.com/MarkDacek/commons-lang


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

Branch: refs/heads/release
Commit: 8147cc5b3de5fa7a3a3e8116355efa44367dc3c5
Parents: ff6b0ad e423b0b
Author: Rob Tompkins <ch...@gmail.com>
Authored: Thu Apr 20 11:08:03 2017 -0400
Committer: Rob Tompkins <ch...@gmail.com>
Committed: Thu Apr 20 11:08:03 2017 -0400

----------------------------------------------------------------------
 .../builder/ReflectionToStringBuilder.java      | 122 +++++++++++++-
 ...ionToStringBuilderExcludeNullValuesTest.java | 161 +++++++++++++++++++
 2 files changed, 282 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8147cc5b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
----------------------------------------------------------------------


[39/50] [lang] StrBuilder: remove commented-out code

Posted by br...@apache.org.
StrBuilder: remove commented-out code


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

Branch: refs/heads/release
Commit: 1375e931d7c7e6de8b297378fc296029d476d7e8
Parents: 7ddfc8a
Author: pascalschumacher <pa...@gmx.net>
Authored: Thu May 4 13:01:38 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Thu May 4 13:01:38 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/lang3/text/StrBuilder.java   | 31 --------------------
 1 file changed, 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1375e931/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
index e7401f3..cb0bf9d 100644
--- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java
@@ -2757,37 +2757,6 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
         }
     }
 
-    //-----------------------------------------------------------------------
-//    /**
-//     * Gets a String version of the string builder by calling the internal
-//     * constructor of String by reflection.
-//     * <p>
-//     * WARNING: You must not use the StrBuilder after calling this method
-//     * as the buffer is now shared with the String object. To ensure this,
-//     * the internal character array is set to null, so you will get
-//     * NullPointerExceptions on all method calls.
-//     *
-//     * @return the builder as a String
-//     */
-//    public String toSharedString() {
-//        try {
-//            Constructor con = String.class.getDeclaredConstructor(
-//                new Class[] {int.class, int.class, char[].class});
-//            con.setAccessible(true);
-//            char[] buffer = buf;
-//            buf = null;
-//            size = -1;
-//            nullText = null;
-//            return (String) con.newInstance(
-//                new Object[] {Integer.valueOf(0), Integer.valueOf(size), buffer});
-//            
-//        } catch (Exception ex) {
-//            ex.printStackTrace();
-//            throw new UnsupportedOperationException("StrBuilder.toSharedString is unsupported: " + ex.getMessage());
-//        }
-//    }
-
-    //-----------------------------------------------------------------------
     /**
      * Checks the contents of this builder against another to see if they
      * contain the same character content ignoring case.


[32/50] [lang] Adding testcase to cover a missing branch.

Posted by br...@apache.org.
Adding testcase to cover a missing branch.


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

Branch: refs/heads/release
Commit: 9766e22b42b7b3f3923cb9c2502dfc2dd5d0a5b0
Parents: ece2f25
Author: Basha <ar...@paypalcorp.com>
Authored: Sat Apr 29 20:05:58 2017 +0530
Committer: Basha <ar...@paypalcorp.com>
Committed: Sat Apr 29 20:06:31 2017 +0530

----------------------------------------------------------------------
 .../commons/lang3/builder/ToStringBuilderTest.java    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9766e22b/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 b218329..8e32287 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.lang3.builder;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assume.assumeFalse;
@@ -838,6 +839,19 @@ public class ToStringBuilderTest {
         assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString());
         assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString());
     }
+    
+    @Test
+    public void testConstructToStringBuilder(){
+        ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null);
+        ToStringBuilder stringBuilder2 = new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, new StringBuffer(1024));
+        assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder1.getStyle());
+        assertNotNull(stringBuilder1.getStringBuffer());
+        assertNotNull(stringBuilder1.toString());
+        assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder2.getStyle());
+        assertNotNull(stringBuilder2.getStringBuffer());
+        assertNotNull(stringBuilder2.toString());
+    }
+
 
     @Test
     public void testObject() {


[29/50] [lang] LANG-1256: Add JMH maven dependencies.

Posted by br...@apache.org.
LANG-1256: Add JMH maven dependencies.

move checkstyle exclusion of JMH generated classes from pom.xml to checkstyle-suppressions.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/d61090ab
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/d61090ab
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/d61090ab

Branch: refs/heads/release
Commit: d61090ab64dcf411d7f1db0b6a9890af74238580
Parents: b7cc7a1
Author: pascalschumacher <pa...@gmx.net>
Authored: Fri Apr 28 21:03:56 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Apr 28 21:03:56 2017 +0200

----------------------------------------------------------------------
 checkstyle-suppressions.xml |  2 ++
 pom.xml                     | 16 ----------------
 2 files changed, 2 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d61090ab/checkstyle-suppressions.xml
----------------------------------------------------------------------
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index 3c02362..359c8dd 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -19,4 +19,6 @@ limitations under the License.
 <suppressions>
     <suppress checks="JavadocMethod" files=".*[/\\]test[/\\].*"/>
     <suppress checks="JavadocPackage" files=".*[/\\]test[/\\].*"/>
+    <!-- exclude generated JMH classes from all checks -->
+    <suppress checks="[a-zA-Z0-9]*" files=".*[/\\]generated-test-sources[/\\].*"/>
 </suppressions>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/d61090ab/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 35cf5b3..481840f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -675,14 +675,6 @@
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
-          <!-- start: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
-          <sourceDirectories>
-            <sourceDirectory>src/main/java</sourceDirectory>
-          </sourceDirectories>
-          <testSourceDirectories>
-            <testSourceDirectory>src/test/java</testSourceDirectory>
-          </testSourceDirectories>
-          <!-- end: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>
@@ -708,14 +700,6 @@
         <configuration>
           <configLocation>${basedir}/checkstyle.xml</configLocation>
           <suppressionsLocation>${basedir}/checkstyle-suppressions.xml</suppressionsLocation>
-          <!-- start: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
-          <sourceDirectories>
-            <sourceDirectory>src/main/java</sourceDirectory>
-          </sourceDirectories>
-          <testSourceDirectories>
-            <testSourceDirectory>src/test/java</testSourceDirectory>
-          </testSourceDirectories>
-          <!-- end: workaround to exclude classes generated by JMH see https://issues.apache.org/jira/browse/MCHECKSTYLE-70 -->
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>


[15/50] [lang] use Validate#notNull instead of "throw new NullPointerException"

Posted by br...@apache.org.
use Validate#notNull instead of "throw new NullPointerException"


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

Branch: refs/heads/release
Commit: 52d6e24d19465e6f468839650c969d5931f66d65
Parents: 82cc244
Author: pascalschumacher <pa...@gmx.net>
Authored: Wed Apr 19 20:17:58 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 20:17:58 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/lang3/ClassUtils.java  |  5 ++---
 .../java/org/apache/commons/lang3/ObjectUtils.java | 16 ++++------------
 src/main/java/org/apache/commons/lang3/Range.java  |  6 ++----
 .../lang3/concurrent/BasicThreadFactory.java       | 17 +++++------------
 .../org/apache/commons/lang3/time/FormatCache.java |  6 +++---
 5 files changed, 16 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/ClassUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ClassUtils.java b/src/main/java/org/apache/commons/lang3/ClassUtils.java
index 012d2a6..60395ef 100644
--- a/src/main/java/org/apache/commons/lang3/ClassUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java
@@ -1053,9 +1053,8 @@ public class ClassUtils {
      */
     private static String toCanonicalName(String className) {
         className = StringUtils.deleteWhitespace(className);
-        if (className == null) {
-            throw new NullPointerException("className must not be null.");
-        } else if (className.endsWith("[]")) {
+        Validate.notNull(className, "className must not be null.");
+        if (className.endsWith("[]")) {
             final StringBuilder classNameBuffer = new StringBuilder();
             while (className.endsWith("[]")) {
                 className = className.substring(0, className.length() - 2);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/ObjectUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
index 2edd81f..13d1256 100644
--- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
@@ -353,9 +353,7 @@ public class ObjectUtils {
      * @since 3.2
      */
     public static void identityToString(final Appendable appendable, final Object object) throws IOException {
-        if (object == null) {
-            throw new NullPointerException("Cannot get the toString of a null identity");
-        }
+        Validate.notNull(object, "Cannot get the toString of a null identity");
         appendable.append(object.getClass().getName())
               .append('@')
               .append(Integer.toHexString(System.identityHashCode(object)));
@@ -379,9 +377,7 @@ public class ObjectUtils {
      */
     @Deprecated
     public static void identityToString(final StrBuilder builder, final Object object) {
-        if (object == null) {
-            throw new NullPointerException("Cannot get the toString of a null identity");
-        }
+        Validate.notNull(object, "Cannot get the toString of a null identity");
         builder.append(object.getClass().getName())
               .append('@')
               .append(Integer.toHexString(System.identityHashCode(object)));
@@ -403,9 +399,7 @@ public class ObjectUtils {
      * @since 2.4
      */
     public static void identityToString(final StringBuffer buffer, final Object object) {
-        if (object == null) {
-            throw new NullPointerException("Cannot get the toString of a null identity");
-        }
+        Validate.notNull(object, "Cannot get the toString of a null identity");
         buffer.append(object.getClass().getName())
               .append('@')
               .append(Integer.toHexString(System.identityHashCode(object)));
@@ -427,9 +421,7 @@ public class ObjectUtils {
      * @since 3.2
      */
     public static void identityToString(final StringBuilder builder, final Object object) {
-        if (object == null) {
-            throw new NullPointerException("Cannot get the toString of a null identity");
-        }
+        Validate.notNull(object, "Cannot get the toString of a null identity");
         builder.append(object.getClass().getName())
               .append('@')
               .append(Integer.toHexString(System.identityHashCode(object)));

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/Range.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/Range.java b/src/main/java/org/apache/commons/lang3/Range.java
index 73e6969..29ad7a3 100644
--- a/src/main/java/org/apache/commons/lang3/Range.java
+++ b/src/main/java/org/apache/commons/lang3/Range.java
@@ -285,10 +285,8 @@ public final class Range<T> implements Serializable {
      * @return -1, 0 or +1 depending on the element's location relative to the range
      */
     public int elementCompareTo(final T element) {
-        if (element == null) {
-            // Comparable API says throw NPE on null
-            throw new NullPointerException("Element is null");
-        }
+        // Comparable API says throw NPE on null
+        Validate.notNull(element, "Element is null");
         if (isAfter(element)) {
             return -1;
         } else if (isBefore(element)) {

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java b/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
index 9164cca..b25a51a 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
@@ -20,6 +20,8 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>
  * An implementation of the {@code ThreadFactory} interface that provides some
@@ -278,10 +280,7 @@ public class BasicThreadFactory implements ThreadFactory {
          * is <b>null</b>
          */
         public Builder wrappedFactory(final ThreadFactory factory) {
-            if (factory == null) {
-                throw new NullPointerException(
-                        "Wrapped ThreadFactory must not be null!");
-            }
+            Validate.notNull(factory, "Wrapped ThreadFactory must not be null!");
 
             wrappedFactory = factory;
             return this;
@@ -296,10 +295,7 @@ public class BasicThreadFactory implements ThreadFactory {
          * @throws NullPointerException if the naming pattern is <b>null</b>
          */
         public Builder namingPattern(final String pattern) {
-            if (pattern == null) {
-                throw new NullPointerException(
-                        "Naming pattern must not be null!");
-            }
+            Validate.notNull(pattern, "Naming pattern must not be null!");
 
             namingPattern = pattern;
             return this;
@@ -341,10 +337,7 @@ public class BasicThreadFactory implements ThreadFactory {
          */
         public Builder uncaughtExceptionHandler(
                 final Thread.UncaughtExceptionHandler handler) {
-            if (handler == null) {
-                throw new NullPointerException(
-                        "Uncaught exception handler must not be null!");
-            }
+            Validate.notNull(handler, "Uncaught exception handler must not be null!");
 
             exceptionHandler = handler;
             return this;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/52d6e24d/src/main/java/org/apache/commons/lang3/time/FormatCache.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/FormatCache.java b/src/main/java/org/apache/commons/lang3/time/FormatCache.java
index affb7ab..22850f6 100644
--- a/src/main/java/org/apache/commons/lang3/time/FormatCache.java
+++ b/src/main/java/org/apache/commons/lang3/time/FormatCache.java
@@ -25,6 +25,8 @@ import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>FormatCache is a cache and factory for {@link Format}s.</p>
  * 
@@ -67,9 +69,7 @@ abstract class FormatCache<F extends Format> {
      *  or <code>null</code>
      */
     public F getInstance(final String pattern, TimeZone timeZone, Locale locale) {
-        if (pattern == null) {
-            throw new NullPointerException("pattern must not be null");
-        }
+        Validate.notNull(pattern, "pattern must not be null");
         if (timeZone == null) {
             timeZone = TimeZone.getDefault();
         }


[41/50] [lang] [LANG-1331] ImmutablePair.nullPair()

Posted by br...@apache.org.
[LANG-1331] ImmutablePair.nullPair()

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

Branch: refs/heads/release
Commit: 776b86e99a1ce18a5093db457109807b766d49c1
Parents: 340f5f7
Author: Gary Gregory <gg...@apache.org>
Authored: Sun May 14 20:33:59 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun May 14 20:33:59 2017 -0700

----------------------------------------------------------------------
 src/changes/changes.xml                         |  1 +
 .../commons/lang3/tuple/ImmutablePair.java      | 18 +++++++++
 .../commons/lang3/tuple/ImmutablePairTest.java  | 42 +++++++++++++++++++-
 3 files changed, 60 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/776b86e9/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index dc6b795..768644c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -90,6 +90,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1313" type="add" dev="pschumacher" due-to="Tomschi">Add ArchUtils - An utility class for the "os.arch" system property</action>
     <action issue="LANG-1272" type="add" dev="ebourg">Add shuffle methods to ArrayUtils</action>
     <action issue="LANG-1317" type="add" dev="pschumacher" due-to="Yasser Zamani">Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods</action>
+    <action issue="LANG-1331" type="add" dev="ggregory">Add ImmutablePair.nullPair()</action>    
   </release>
 
   <release version="3.5" date="2016-10-13" description="New features including Java 9 detection">

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/776b86e9/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
index c2b92be..689ad24 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
@@ -33,9 +33,27 @@ package org.apache.commons.lang3.tuple;
  */
 public final class ImmutablePair<L, R> extends Pair<L, R> {
 
+    /**
+     * An immutable pair of nulls.
+     */
+    // This is not defined with generics to avoid warnings in call sites.
+    @SuppressWarnings("rawtypes")
+    private static final ImmutablePair NULL = ImmutablePair.of(null, null);
+
     /** Serialization version */
     private static final long serialVersionUID = 4954918890077093841L;
 
+    /** 
+     * Returns an immutable pair of nulls.
+     * 
+     * @return an immutable pair of nulls. 
+     * @since 3.6
+     */
+    @SuppressWarnings("rawtypes")
+    public static <L, R> ImmutablePair<L, R> nullPair() {
+        return NULL;
+    }
+    
     /** Left object */
     public final L left;
     /** Right object */

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/776b86e9/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
index f73d7b5..eaedef3 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java
@@ -18,7 +18,9 @@ package org.apache.commons.lang3.tuple;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
@@ -76,7 +78,45 @@ public class ImmutablePairTest {
     public void testHashCode() throws Exception {
         assertEquals(ImmutablePair.of(null, "foo").hashCode(), ImmutablePair.of(null, "foo").hashCode());
     }
-
+    
+    @Test
+    public void testNullPairEquals() {
+        assertEquals(ImmutablePair.nullPair(), ImmutablePair.nullPair());
+    }
+        
+    @Test
+    public void testNullPairSame() {
+        assertSame(ImmutablePair.nullPair(), ImmutablePair.nullPair());
+    }
+        
+    @Test
+    public void testNullPairLeft() {
+        assertNull(ImmutablePair.nullPair().getLeft());
+    }
+        
+    @Test
+    public void testNullPairKey() {
+        assertNull(ImmutablePair.nullPair().getKey());
+    }
+        
+    @Test
+    public void testNullPairRight() {
+        assertNull(ImmutablePair.nullPair().getRight());
+    }
+        
+    @Test
+    public void testNullPairValue() {
+        assertNull(ImmutablePair.nullPair().getValue());
+    }
+        
+    @Test
+    public void testNullPairTyped() {
+        // No compiler warnings
+        // How do we assert that?
+        ImmutablePair<String, String> pair = ImmutablePair.nullPair();
+        assertNotNull(pair);
+    }
+        
     @Test
     public void testToString() throws Exception {
         assertEquals("(null,null)", ImmutablePair.of(null, null).toString());


[04/50] [lang] LANG-1167: Added license to top of ReflectionToStringBuilderExcludeNullValuesTest.java

Posted by br...@apache.org.
LANG-1167: Added license to top of ReflectionToStringBuilderExcludeNullValuesTest.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/e423b0bc
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/e423b0bc
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/e423b0bc

Branch: refs/heads/release
Commit: e423b0bc2dea4167ad98fffc1afd9243ba73aad6
Parents: 3c2673e
Author: MarkDacek <ma...@richmond.edu>
Authored: Sat Mar 18 18:49:40 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sat Mar 18 18:49:40 2017 -0400

----------------------------------------------------------------------
 ...ectionToStringBuilderExcludeNullValuesTest.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e423b0bc/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
index 7c0c68a..0a91609 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -1,3 +1,20 @@
+/*
+ * 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.lang3.builder;
 
 import static org.junit.Assert.*;


[43/50] [lang] [LANG-1332] ImmutableTriple.nullTriple()

Posted by br...@apache.org.
[LANG-1332] ImmutableTriple.nullTriple()

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

Branch: refs/heads/release
Commit: 585b1cb97b4b9e81b55d68e04b6c1e1195058a8f
Parents: e1bc286
Author: Gary Gregory <gg...@apache.org>
Authored: Sun May 14 20:41:59 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun May 14 20:41:59 2017 -0700

----------------------------------------------------------------------
 src/changes/changes.xml                         |  1 +
 .../commons/lang3/tuple/ImmutableTriple.java    | 18 ++++++++++
 .../lang3/tuple/ImmutableTripleTest.java        | 35 ++++++++++++++++++++
 3 files changed, 54 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/585b1cb9/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 768644c..c106896 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -91,6 +91,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1272" type="add" dev="ebourg">Add shuffle methods to ArrayUtils</action>
     <action issue="LANG-1317" type="add" dev="pschumacher" due-to="Yasser Zamani">Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods</action>
     <action issue="LANG-1331" type="add" dev="ggregory">Add ImmutablePair.nullPair()</action>    
+    <action issue="LANG-1332" type="add" dev="ggregory">Add ImmutableTriple.nullTriple()</action>    
   </release>
 
   <release version="3.5" date="2016-10-13" description="New features including Java 9 detection">

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/585b1cb9/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
index 68ef742..49f5746 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
@@ -34,9 +34,27 @@ package org.apache.commons.lang3.tuple;
  */
 public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> {
 
+    /**
+     * An immutable triple of nulls.
+     */
+    // This is not defined with generics to avoid warnings in call sites.
+    @SuppressWarnings("rawtypes")
+    private static final ImmutableTriple NULL = ImmutableTriple.of(null, null, null);
+
     /** Serialization version */
     private static final long serialVersionUID = 1L;
 
+    /** 
+     * Returns an immutable triple of nulls.
+     * 
+     * @return an immutable triple of nulls. 
+     * @since 3.6
+     */
+    @SuppressWarnings("unchecked")
+    public static <L, M, R> ImmutableTriple<L, M, R> nullTriple() {
+        return NULL;
+    }
+    
     /** Left object */
     public final L left;
     /** Middle object */

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/585b1cb9/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
index 3e36932..3be6660 100644
--- a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
+++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java
@@ -18,7 +18,9 @@ package org.apache.commons.lang3.tuple;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
@@ -86,6 +88,39 @@ public class ImmutableTripleTest {
     }
 
     @Test
+    public void testNullTripleEquals() {
+        assertEquals(ImmutableTriple.nullTriple(), ImmutableTriple.nullTriple());
+    }
+        
+    @Test
+    public void testNullTripleSame() {
+        assertSame(ImmutableTriple.nullTriple(), ImmutableTriple.nullTriple());
+    }
+        
+    @Test
+    public void testNullTripleLeft() {
+        assertNull(ImmutableTriple.nullTriple().getLeft());
+    }
+        
+    @Test
+    public void testNullTripleMiddle() {
+        assertNull(ImmutableTriple.nullTriple().getMiddle());
+    }
+                
+    @Test
+    public void testNullTripleRight() {
+        assertNull(ImmutableTriple.nullTriple().getRight());
+    }
+        
+    @Test
+    public void testNullTripleTyped() {
+        // No compiler warnings
+        // How do we assert that?
+        ImmutableTriple<String, String, String> triple = ImmutableTriple.nullTriple();
+        assertNotNull(triple);
+    }
+
+    @Test
     public void testToString() throws Exception {
         assertEquals("(null,null,null)", ImmutableTriple.of(null, null, null).toString());
         assertEquals("(null,two,null)", ImmutableTriple.of(null, "two", null).toString());


[40/50] [lang] pom.xml: add goals executed on travis as defaultGoal to make it easy to run the same checks locally

Posted by br...@apache.org.
pom.xml: add goals executed on travis as defaultGoal to make it easy to run the same checks locally


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

Branch: refs/heads/release
Commit: 340f5f70e970a85c760416569ad877bf7209b6b6
Parents: 1375e93
Author: pascalschumacher <pa...@gmx.net>
Authored: Thu May 4 21:27:40 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Thu May 4 21:27:40 2017 +0200

----------------------------------------------------------------------
 pom.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/340f5f70/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 481840f..6346074 100644
--- a/pom.xml
+++ b/pom.xml
@@ -603,6 +603,7 @@
 
 
   <build>
+   <defaultGoal>clean test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc</defaultGoal>
    <pluginManagement>
       <plugins>
         <plugin>


[35/50] [lang] LANG-1307: Add getDigits method to StringUtils

Posted by br...@apache.org.
LANG-1307: Add getDigits method to StringUtils

add since javadoc tag and changes.xml entry


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

Branch: refs/heads/release
Commit: 610caab590fe224c02c8f509431f6428fe8e1063
Parents: 9b3257e
Author: pascalschumacher <pa...@gmx.net>
Authored: Mon May 1 11:08:10 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Mon May 1 11:08:10 2017 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                                 | 1 +
 src/main/java/org/apache/commons/lang3/StringUtils.java | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/610caab5/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a679df8..6c3957a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.6" date="2017-MM-DD" description="TBD">
+    <action issue="LANG-1307" type="add" dev="pschumacher" due-to="Arshad Basha">Add a method in StringUtils to extract only digits out of input string</action>
     <action issue="LANG-1110" type="update" dev="pschumacher" due-to="Bruno P. Kinoshita">Implement HashSetvBitSetTest using JMH</action>
     <action issue="LANG-1256" type="add" dev="pschumacher" due-to="C0rWin">Add JMH maven dependencies</action>
     <action issue="LANG-1167" type="add" dev="chtompki" due-to="Mark Dacek">Add null filter to ReflectionToStringBuilder</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/610caab5/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 6ab1118..cf398d1 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -7176,6 +7176,7 @@ public class StringUtils {
      * @return String with only digits,
      *           or an empty ("") String if no digits found,
      *           or {@code null} String if {@code str} is null
+     * @since 3.6
      */
     public static String getDigits(final String str) {
         if (isEmpty(str)) {


[06/50] [lang] [LANG-1291] Provide annotations to document thread safety.

Posted by br...@apache.org.
[LANG-1291] Provide annotations to document thread safety.

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

Branch: refs/heads/release
Commit: a91f76da21faf4e8b70f0f69c6db2521409e7d29
Parents: a5e76eb
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Apr 17 12:00:09 2017 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Mon Apr 17 12:00:09 2017 -0700

----------------------------------------------------------------------
 .../concurrent/annotation/ContractTest.java     | 38 ++++++++++++++++++++
 .../annotation/ContractTestFixture.java         | 25 +++++++++++++
 2 files changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a91f76da/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java
new file mode 100644
index 0000000..affa786
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.lang3.concurrent.annotation;
+
+import org.junit.Test;
+
+/**
+ * Tests {@link Contract}.
+ */
+public class ContractTest {
+
+    @Test
+    public void testClassAnnotationInClassFile() throws Exception {
+        AnnotationTestUtils.testClassAnnotationInClassFile(
+                "org.apache.commons.lang3.concurrent.annotation.ContractTestFixture",
+                "Lorg/apache/commons/lang3/concurrent/annotation/Contract;");
+    }
+
+    @Test
+    public void testMethodAnnotationNotRetainedAtRuntime() {
+        AnnotationTestUtils.testMethodAnnotationNotRetainedAtRuntime(ContractTestFixture.class, Contract.class);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a91f76da/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java
new file mode 100644
index 0000000..6d254b1
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/concurrent/annotation/ContractTestFixture.java
@@ -0,0 +1,25 @@
+/*
+ * 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.lang3.concurrent.annotation;
+
+/**
+ * Tests {@link Immutable}.
+ */
+@Contract()
+public class ContractTestFixture {
+    // empty
+}


[49/50] [lang] Update website for 3.6 release

Posted by br...@apache.org.
Update website for 3.6 release


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

Branch: refs/heads/release
Commit: cc06d265a7c2a8147cbbd96656263f45ae8a44dc
Parents: 964496a
Author: Benedikt Ritter <br...@apache.org>
Authored: Mon Apr 17 14:12:54 2017 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:59:25 2017 -0400

----------------------------------------------------------------------
 README.md                         |  2 +-
 RELEASE-NOTES.txt                 |  2 +-
 pom.xml                           |  2 +-
 src/changes/changes.xml           |  6 +++---
 src/site/xdoc/download_lang.xml   |  2 +-
 src/site/xdoc/index.xml           | 10 +++++-----
 src/site/xdoc/release-history.xml |  3 +++
 7 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index dd44aab..ae5aee2 100644
--- a/README.md
+++ b/README.md
@@ -68,7 +68,7 @@ Alternatively you can pull it from the central Maven repositories:
 <dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-lang3</artifactId>
-  <version>3.5</version>
+  <version>3.6</version>
 </dependency>
 ```
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 3afdb1f..d45c82e 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -9,7 +9,7 @@ This document contains the release notes for the 3.6 version of
 Apache Commons Lang as well as a history all changes in the Commons Lang 3.x
 release line. Commons Lang is a set of utility functions and reusable
 components that should be of use in any Java environment. Commons Lang 3.6 at
-least requires Java 7. Note that this has changed from Commons Lang 3.5, which
+least requires Java 7.0. Note that this has changed from Commons Lang 3.5, which
 only required Java 1.6.
 
 For the advice on upgrading from 2.x to 3.x, see the following page:

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5aa7856..09607c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -578,7 +578,7 @@
     <commons.componentid>lang3</commons.componentid>
     <!-- Current 3.x release series -->
     <commons.release.version>3.6</commons.release.version>
-    <commons.release.desc>(Java 6.0+)</commons.release.desc>
+    <commons.release.desc>(Java 7.0+)</commons.release.desc>
     <!-- Previous 2.x release series -->
     <commons.release.2.version>2.6</commons.release.2.version>
     <commons.release.2.desc>(Requires Java 1.2 or later)</commons.release.2.desc>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6a22895..bab6b9a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,7 +45,7 @@ The <action> type attribute can be add,update,fix,remove.
   </properties>
   <body>
 
-  <release version="3.6" date="2017-MM-DD" description="TBD">
+  <release version="3.6" date="2017-05-17" description="New features and bug fixes. Requires Java 7.">
     <action issue="LANG-1325" type="add" dev="kinow" due-to="Arshad Basha">Increase test coverage of ToStringBuilder class to 100%</action>
     <action issue="LANG-1307" type="add" dev="pschumacher" due-to="Arshad Basha">Add a method in StringUtils to extract only digits out of input string</action>
     <action issue="LANG-1110" type="update" dev="pschumacher" due-to="Bruno P. Kinoshita">Implement HashSetvBitSetTest using JMH</action>
@@ -89,8 +89,8 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1313" type="add" dev="pschumacher" due-to="Tomschi">Add ArchUtils - An utility class for the "os.arch" system property</action>
     <action issue="LANG-1272" type="add" dev="ebourg">Add shuffle methods to ArrayUtils</action>
     <action issue="LANG-1317" type="add" dev="pschumacher" due-to="Yasser Zamani">Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods</action>
-    <action issue="LANG-1331" type="add" dev="ggregory">Add ImmutablePair.nullPair()</action>    
-    <action issue="LANG-1332" type="add" dev="ggregory">Add ImmutableTriple.nullTriple()</action>    
+    <action issue="LANG-1331" type="add" dev="ggregory">Add ImmutablePair.nullPair()</action>
+    <action issue="LANG-1332" type="add" dev="ggregory">Add ImmutableTriple.nullTriple()</action>
   </release>
 
   <release version="3.5" date="2016-10-13" description="New features including Java 9 detection">

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/src/site/xdoc/download_lang.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/download_lang.xml b/src/site/xdoc/download_lang.xml
index 3f752c8..55e00dd 100644
--- a/src/site/xdoc/download_lang.xml
+++ b/src/site/xdoc/download_lang.xml
@@ -111,7 +111,7 @@ limitations under the License.
       </p>
     </subsection>
     </section>
-    <section name="Apache Commons Lang 3.6 (Java 6.0+)">
+    <section name="Apache Commons Lang 3.6 (Java 7.0+)">
       <subsection name="Binaries">
         <table>
           <tr>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index e85850b..2d8b15e 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -50,7 +50,7 @@ and various <a href="project-reports.html">project reports</a> are provided.
 The JavaDoc API documents are available online:
 </p>
 <ul>
-<li>The <a href="javadocs/api-3.5/index.html">current stable release 3.5</a> [Java 6.0+]</li>
+<li>The <a href="javadocs/api-3.6/index.html">current stable release 3.6</a> [Java 7.0+]</li>
 <li>The <a href="javadocs/api-2.6/index.html">legacy release 2.6</a> [Java 1.2+]</li>
 <li>Older releases - see the <a href="release-history.html">Release History</a> page</li>
 </ul>
@@ -61,10 +61,10 @@ The <a href="source-repository.html">git repository</a> can be
 </section>
 <!-- ================================================== -->
 <section name="Release Information">
-<p>The latest stable release of Lang is 3.5. You may: </p>
+<p>The latest stable release of Lang is 3.6. You may: </p>
 <ul>
-<li>Download <a href="http://commons.apache.org/lang/download_lang.cgi">3.5</a></li>
-<li>Read the <a href="release-notes/RELEASE-NOTES-3.5.txt">3.5 release notes</a></li>
+<li>Download <a href="http://commons.apache.org/lang/download_lang.cgi">3.6</a></li>
+<li>Read the <a href="release-notes/RELEASE-NOTES-3.6.txt">3.6 release notes</a></li>
 <li>Examine the <a href="article3_0.html">2.x to 3.0 upgrade notes</a></li>
 <li>Compare major versions via the <a href="lang2-lang3-clirr-report.html">Lang2 to Lang3 Clirr report</a></li>
 </ul>
@@ -74,7 +74,7 @@ Alternatively you can pull it from the central Maven repositories:
 &lt;dependency&gt;
   &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
   &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
-  &lt;version&gt;3.5&lt;/version&gt;
+  &lt;version&gt;3.6&lt;/version&gt;
 &lt;/dependency&gt;
 </pre>
 </p>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cc06d265/src/site/xdoc/release-history.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/release-history.xml b/src/site/xdoc/release-history.xml
index 8a805e1..57ba62d 100644
--- a/src/site/xdoc/release-history.xml
+++ b/src/site/xdoc/release-history.xml
@@ -32,6 +32,9 @@ limitations under the License.
           <th>Version</th><th>Release date</th><th>Required Java Version</th><th>Javadoc</th><th>Release notes</th>
         </tr>
         <tr>
+          <td>3.6</td><td>2016-04-17</td><td>7.0</td><td><a href="javadocs/api-3.6/">api-3.6</a></td><td><a href="release-notes/RELEASE-NOTES-3.6.txt">release notes for 3.6</a></td>
+        </tr>
+        <tr>
           <td>3.5</td><td>2016-10-02</td><td>6.0</td><td><a href="javadocs/api-3.5/">api-3.5</a></td><td><a href="release-notes/RELEASE-NOTES-3.5.txt">release notes for 3.5</a></td>
         </tr>
         <tr>


[02/50] [lang] LANG-1167: Added isExcludeNullValues to ReflectionToStringBuilder and test

Posted by br...@apache.org.
LANG-1167: Added isExcludeNullValues to ReflectionToStringBuilder and test


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

Branch: refs/heads/release
Commit: 661d16d190708a1a396d8b75ba10738e4574c11d
Parents: 40b8ecd
Author: MarkDacek <ma...@richmond.edu>
Authored: Sat Mar 18 15:47:09 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sat Mar 18 15:47:09 2017 -0400

----------------------------------------------------------------------
 .../builder/ReflectionToStringBuilder.java      | 122 ++++++++++++++++++-
 ...ionToStringBuilderExcludeNullValuesTest.java |  99 +++++++++++++++
 2 files changed, 220 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/661d16d1/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 d40a838..0b4d7e5 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -300,6 +300,64 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
         return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics)
                 .toString();
     }
+    
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputTransients</code> is <code>true</code>, transient fields will be output, otherwise they
+     * are ignored, as they are likely derived fields, and not part of the value of the Object.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputStatics</code> is <code>true</code>, static fields will be output, otherwise they are
+     * ignored.
+     * </p>
+     *
+     * <p>
+     * Superclass fields will be appended up to and including the specified superclass. A null superclass is treated as
+     * <code>java.lang.Object</code>.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @param <T>
+     *            the type of the object
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include static fields
+     * @param excludeNulls
+     *            whether to exclude fields whose values are null
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     * 
+     * @see ToStringExclude
+     * @since 2.1
+     */
+    public static <T> String toString(
+            final T object, final ToStringStyle style, final boolean outputTransients,
+            final boolean outputStatics, boolean excludeNulls, final Class<? super T> reflectUpToClass) {
+        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNulls)
+                .toString();
+    }
 
     /**
      * Builds a String for a toString method excluding the given field names.
@@ -379,6 +437,11 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      * Whether or not to append transient fields.
      */
     private boolean appendTransients = false;
+    
+    /**
+     * Whether or not to append fields that are null.
+     */
+    private boolean excludeNullValues;
 
     /**
      * Which field names to exclude from output. Intended for fields like <code>"password"</code>.
@@ -483,6 +546,38 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
         this.setAppendTransients(outputTransients);
         this.setAppendStatics(outputStatics);
     }
+    
+    /**
+     * Constructor.
+     *
+     * @param <T>
+     *            the type of the object
+     * @param object
+     *            the Object to build a <code>toString</code> for
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param buffer
+     *            the <code>StringBuffer</code> to populate, may be <code>null</code>
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include static fields
+     * @param excludeNullValues
+     *            whether to exclude fields who value is null
+     * @since 2.1
+     */
+    public <T> ReflectionToStringBuilder(
+            final T object, final ToStringStyle style, final StringBuffer buffer,
+            final Class<? super T> reflectUpToClass, final boolean outputTransients, final boolean outputStatics,
+            final boolean excludeNullValues) {
+        super(checkNotNull(object), style, buffer);
+        this.setUpToClass(reflectUpToClass);
+        this.setAppendTransients(outputTransients);
+        this.setAppendStatics(outputStatics);
+        this.setExcludeNullValues(excludeNullValues);
+    }
 
     /**
      * Returns whether or not to append the given <code>Field</code>.
@@ -547,7 +642,9 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
                     // Warning: Field.get(Object) creates wrappers objects
                     // for primitive types.
                     final Object fieldValue = this.getValue(field);
-                    this.append(fieldName, fieldValue);
+                    if(!excludeNullValues || fieldValue != null){
+                        this.append(fieldName, fieldValue);
+                    }
                 } catch (final IllegalAccessException ex) {
                     //this can't happen. Would get a Security exception
                     // instead
@@ -619,6 +716,17 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     public boolean isAppendTransients() {
         return this.appendTransients;
     }
+    
+    /**
+     * <p>
+     * Gets whether or not to append fields whose values are null.
+     * </p>
+     *
+     * @return Whether or not to append fields whose values are null.
+     */
+    public boolean isExcludeNullValues() {
+        return this.excludeNullValues;
+    }
 
     /**
      * <p>
@@ -658,6 +766,18 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     public void setAppendTransients(final boolean appendTransients) {
         this.appendTransients = appendTransients;
     }
+    
+    /**
+     * <p>
+     * Sets whether or not to append fields whose values are null.
+     * </p>
+     *
+     * @param excludeNullValues
+     *            Whether or not to append fields whose values are null.
+     */
+    public void setExcludeNullValues(final boolean excludeNullValues) {
+        this.excludeNullValues = excludeNullValues;
+    }
 
     /**
      * Sets the field names to exclude.

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/661d16d1/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
new file mode 100644
index 0000000..be368d6
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -0,0 +1,99 @@
+package org.apache.commons.lang3.builder;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ReflectionToStringBuilderExcludeNullValuesTest {
+
+    class TestFixture{
+        private Integer testIntegerField;
+        private String testStringField;
+        
+        public TestFixture(Integer a, String b){
+            this.testIntegerField = a;
+            this.testStringField = b;
+        }
+    }
+    
+    private static final String INTEGER_FIELD_NAME = "testIntegerField";
+    private static final String STRING_FIELD_NAME = "testStringField";
+    private final TestFixture BOTH_NON_NULL = new TestFixture(0, "str");
+    private final TestFixture FIRST_NULL = new TestFixture(null, "str");
+    private final TestFixture SECOND_NULL = new TestFixture(0, null);
+    private final TestFixture BOTH_NULL = new TestFixture(null, null);
+    
+    @Test
+    public void test_NonExclude(){
+        //normal case=
+        String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //make one null
+        toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //other one null
+        toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+
+        //make the both null
+        toString = ReflectionToStringBuilder.toString(BOTH_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_excludeNull(){
+        
+        //test normal case
+        String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, true, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //make one null
+        toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, true, null);
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //other one null
+        toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, true, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        
+        //both null
+        toString = ReflectionToStringBuilder.toString(BOTH_NULL, null, false, false, true, null);
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_ConstructorOption(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, false);
+        builder.setExcludeNullValues(true);
+        assertTrue(builder.isExcludeNullValues());
+        
+        String toString = builder.toString();
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(FIRST_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(SECOND_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+    }
+
+}


[10/50] [lang] Exclude SF_SWITCH_NO_DEFAULT on FastDateParser

Posted by br...@apache.org.
Exclude SF_SWITCH_NO_DEFAULT on FastDateParser

FastDateParser#simpleQuote uses a switch case that actually has a
default branch in it, but doesn't use break statements.

SF_SWITCH_NO_DEFAULT unfortunately cannot recognize this pattern, and
leave us with no choice but to suppress it.


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

Branch: refs/heads/release
Commit: c40dcf659897edb26affa408c3fa62e80f906550
Parents: 3304965
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:18:53 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c40dcf65/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index f7623df..772052a 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -139,9 +139,14 @@
     <Method name="insertFormats" />
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
+  <!-- Reason: FindBugs does not correctly recognize default branches in switch statements without break statements.
+   See, e.g., the report at https://sourceforge.net/p/findbugs/bugs/1298 -->
   <Match>
     <Class name="org.apache.commons.lang3.time.FastDateParser"/>
-    <Method name="getStrategy" />
+    <Or>
+      <Method name="getStrategy" />
+      <Method name="simpleQuote" params="java.lang.StringBuilder, java.lang.String"/>
+    </Or>
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
 


[44/50] [lang] Add missing JavaDocs to make Checkstyle happy

Posted by br...@apache.org.
Add missing JavaDocs to make Checkstyle happy


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

Branch: refs/heads/release
Commit: 5a87fa172eb1368fe413af34511d1eb3f2674a9f
Parents: 585b1cb
Author: Benedikt Ritter <br...@apache.org>
Authored: Wed May 17 10:14:07 2017 -0400
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed May 17 10:14:07 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/commons/lang3/tuple/ImmutablePair.java   | 8 +++++---
 .../java/org/apache/commons/lang3/tuple/ImmutableTriple.java | 7 +++++--
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/5a87fa17/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
index 85409fe..3df3a7f 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java
@@ -43,10 +43,12 @@ public final class ImmutablePair<L, R> extends Pair<L, R> {
     /** Serialization version */
     private static final long serialVersionUID = 4954918890077093841L;
 
-    /** 
+    /**
      * Returns an immutable pair of nulls.
-     * 
-     * @return an immutable pair of nulls. 
+     *
+     * @param <L> the left element of this pair. Value is {@code null}.
+     * @param <R> the right element of this pair. Value is {@code null}.
+     * @return an immutable pair of nulls.
      * @since 3.6
      */
     @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/5a87fa17/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
index 49f5746..83e212e 100644
--- a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
+++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java
@@ -44,9 +44,12 @@ public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> {
     /** Serialization version */
     private static final long serialVersionUID = 1L;
 
-    /** 
+    /**
      * Returns an immutable triple of nulls.
-     * 
+     *
+     * @param <L> the left element of this triple. Value is {@code null}.
+     * @param <M> the middle element of this triple. Value is {@code null}.
+     * @param <R> the right element of this triple. Value is {@code null}.
      * @return an immutable triple of nulls. 
      * @since 3.6
      */


[37/50] [lang] LANG-1325: update changes.xml

Posted by br...@apache.org.
LANG-1325: update 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/88da5f49
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/88da5f49
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/88da5f49

Branch: refs/heads/release
Commit: 88da5f49bcaf798712274d60d378ddaebfaa20c2
Parents: af32371
Author: Bruno P. Kinoshita <ki...@apache.org>
Authored: Mon May 1 21:48:04 2017 +1200
Committer: Bruno P. Kinoshita <ki...@apache.org>
Committed: Mon May 1 21:48:04 2017 +1200

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


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/88da5f49/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6c3957a..dc6b795 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.6" date="2017-MM-DD" description="TBD">
+    <action issue="LANG-1325" type="add" dev="kinow" due-to="Arshad Basha">Increase test coverage of ToStringBuilder class to 100%</action>
     <action issue="LANG-1307" type="add" dev="pschumacher" due-to="Arshad Basha">Add a method in StringUtils to extract only digits out of input string</action>
     <action issue="LANG-1110" type="update" dev="pschumacher" due-to="Bruno P. Kinoshita">Implement HashSetvBitSetTest using JMH</action>
     <action issue="LANG-1256" type="add" dev="pschumacher" due-to="C0rWin">Add JMH maven dependencies</action>


[16/50] [lang] use Validate#isTrue to validate arguments

Posted by br...@apache.org.
use Validate#isTrue to validate arguments


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

Branch: refs/heads/release
Commit: ff6b0ada72106d67aef1ee21d51bacac2f3af7ac
Parents: 52d6e24
Author: pascalschumacher <pa...@gmx.net>
Authored: Wed Apr 19 21:07:05 2017 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 21:07:05 2017 +0200

----------------------------------------------------------------------
 .../org/apache/commons/lang3/CharRange.java     |  4 +-
 .../org/apache/commons/lang3/CharUtils.java     | 12 +--
 .../commons/lang3/SerializationUtils.java       | 12 +--
 .../org/apache/commons/lang3/ThreadUtils.java   | 36 ++------
 .../commons/lang3/builder/DiffBuilder.java      | 93 ++++++--------------
 .../commons/lang3/builder/DiffResult.java       | 17 ++--
 .../commons/lang3/builder/HashCodeBuilder.java  |  5 +-
 .../builder/ReflectionToStringBuilder.java      |  5 +-
 .../commons/lang3/builder/ToStringBuilder.java  |  5 +-
 .../CallableBackgroundInitializer.java          |  6 +-
 .../concurrent/MultiBackgroundInitializer.java  | 12 +--
 .../commons/lang3/exception/ExceptionUtils.java |  9 +-
 .../org/apache/commons/lang3/math/Fraction.java | 18 ++--
 .../commons/lang3/math/IEEE754rUtils.java       | 21 +----
 .../apache/commons/lang3/math/NumberUtils.java  |  4 +-
 .../apache/commons/lang3/time/DateUtils.java    | 33 +++----
 16 files changed, 86 insertions(+), 206 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/CharRange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java
index 2ccda7c..bf82805 100644
--- a/src/main/java/org/apache/commons/lang3/CharRange.java
+++ b/src/main/java/org/apache/commons/lang3/CharRange.java
@@ -179,9 +179,7 @@ final class CharRange implements Iterable<Character>, Serializable {
      * @throws IllegalArgumentException if {@code null} input
      */
     public boolean contains(final CharRange range) {
-        if (range == null) {
-            throw new IllegalArgumentException("The Range must not be null");
-        }
+        Validate.isTrue(range != null, "The Range must not be null");
         if (negated) {
             if (range.negated) {
                 return start >= range.start && end <= range.end;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/CharUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/CharUtils.java b/src/main/java/org/apache/commons/lang3/CharUtils.java
index 92a8d44..bb45e5f 100644
--- a/src/main/java/org/apache/commons/lang3/CharUtils.java
+++ b/src/main/java/org/apache/commons/lang3/CharUtils.java
@@ -128,9 +128,7 @@ public class CharUtils {
      * @throws IllegalArgumentException if the Character is null
      */
     public static char toChar(final Character ch) {
-        if (ch == null) {
-            throw new IllegalArgumentException("The Character must not be null");
-        }
+        Validate.isTrue(ch != null, "The Character must not be null");
         return ch.charValue();
     }
     
@@ -171,9 +169,7 @@ public class CharUtils {
      * @throws IllegalArgumentException if the String is empty
      */
     public static char toChar(final String str) {
-        if (StringUtils.isEmpty(str)) {
-            throw new IllegalArgumentException("The String must not be empty");
-        }
+        Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty");
         return str.charAt(0);
     }
     
@@ -261,9 +257,7 @@ public class CharUtils {
      * @throws IllegalArgumentException if the Character is not ASCII numeric or is null
      */
     public static int toIntValue(final Character ch) {
-        if (ch == null) {
-            throw new IllegalArgumentException("The character must not be null");
-        }
+        Validate.isTrue(ch != null, "The character must not be null");
         return toIntValue(ch.charValue());
     }
     

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/SerializationUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java
index f1a4993..670ef18 100644
--- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java
+++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java
@@ -133,9 +133,7 @@ public class SerializationUtils {
      * @throws SerializationException (runtime) if the serialization fails
      */
     public static void serialize(final Serializable obj, final OutputStream outputStream) {
-        if (outputStream == null) {
-            throw new IllegalArgumentException("The OutputStream must not be null");
-        }
+        Validate.isTrue(outputStream != null, "The OutputStream must not be null");
         try (ObjectOutputStream out = new ObjectOutputStream(outputStream)){
             out.writeObject(obj);
         } catch (final IOException ex) {
@@ -190,9 +188,7 @@ public class SerializationUtils {
      *             (runtime) if the serialization fails
      */
     public static <T> T deserialize(final InputStream inputStream) {
-        if (inputStream == null) {
-            throw new IllegalArgumentException("The InputStream must not be null");
-        }
+        Validate.isTrue(inputStream != null, "The InputStream must not be null");
         try (ObjectInputStream in = new ObjectInputStream(inputStream)) {
             @SuppressWarnings("unchecked")
             final T obj = (T) in.readObject();
@@ -223,9 +219,7 @@ public class SerializationUtils {
      *             (runtime) if the serialization fails
      */
     public static <T> T deserialize(final byte[] objectData) {
-        if (objectData == null) {
-            throw new IllegalArgumentException("The byte[] must not be null");
-        }
+        Validate.isTrue(objectData != null, "The byte[] must not be null");
         return SerializationUtils.<T>deserialize(new ByteArrayInputStream(objectData));
     }
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/ThreadUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ThreadUtils.java b/src/main/java/org/apache/commons/lang3/ThreadUtils.java
index 93a48b7..9282ed3 100644
--- a/src/main/java/org/apache/commons/lang3/ThreadUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ThreadUtils.java
@@ -50,9 +50,7 @@ public class ThreadUtils {
      *          thread groups from this thread's thread group up to the system thread group
      */
     public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) {
-        if (threadGroup == null) {
-            throw new IllegalArgumentException("The thread group must not be null");
-        }
+        Validate.isTrue(threadGroup != null, "The thread group must not be null");
         final Thread thread = findThreadById(threadId);
         if(thread != null && threadGroup.equals(thread.getThreadGroup())) {
             return thread;
@@ -75,9 +73,7 @@ public class ThreadUtils {
      *          thread groups from this thread's thread group up to the system thread group
      */
     public static Thread findThreadById(final long threadId, final String threadGroupName) {
-        if (threadGroupName == null) {
-            throw new IllegalArgumentException("The thread group name must not be null");
-        }
+        Validate.isTrue(threadGroupName != null, "The thread group name must not be null");
         final Thread thread = findThreadById(threadId);
         if(thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) {
             return thread;
@@ -118,12 +114,8 @@ public class ThreadUtils {
      *          thread groups from this thread's thread group up to the system thread group
      */
     public static Collection<Thread> findThreadsByName(final String threadName, final String threadGroupName) {
-        if (threadName == null) {
-            throw new IllegalArgumentException("The thread name must not be null");
-        }
-        if (threadGroupName == null) {
-            throw new IllegalArgumentException("The thread group name must not be null");
-        }
+        Validate.isTrue(threadName != null, "The thread name must not be null");
+        Validate.isTrue(threadGroupName != null, "The thread group name must not be null");
 
         final Collection<ThreadGroup> threadGroups = findThreadGroups(new NamePredicate(threadGroupName));
 
@@ -311,9 +303,7 @@ public class ThreadUtils {
          */
         public NamePredicate(final String name) {
             super();
-            if (name == null) {
-                throw new IllegalArgumentException("The name must not be null");
-            }
+            Validate.isTrue(name != null, "The name must not be null");
             this.name = name;
         }
 
@@ -398,12 +388,8 @@ public class ThreadUtils {
      *          thread groups from this thread's thread group up to the system thread group
      */
     public static Collection<Thread> findThreads(final ThreadGroup group, final boolean recurse, final ThreadPredicate predicate) {
-        if (group == null) {
-            throw new IllegalArgumentException("The group must not be null");
-        }
-        if (predicate == null) {
-            throw new IllegalArgumentException("The predicate must not be null");
-        }
+        Validate.isTrue(group != null, "The group must not be null");
+        Validate.isTrue(predicate != null, "The predicate must not be null");
 
         int count = group.activeCount();
         Thread[] threads;
@@ -434,12 +420,8 @@ public class ThreadUtils {
      *          thread groups from this thread's thread group up to the system thread group
      */
     public static Collection<ThreadGroup> findThreadGroups(final ThreadGroup group, final boolean recurse, final ThreadGroupPredicate predicate){
-        if (group == null) {
-            throw new IllegalArgumentException("The group must not be null");
-        }
-        if (predicate == null) {
-            throw new IllegalArgumentException("The predicate must not be null");
-        }
+        Validate.isTrue(group != null, "The group must not be null");
+        Validate.isTrue(predicate != null, "The predicate must not be null");
 
         int count = group.activeGroupCount();
         ThreadGroup[] threadGroups;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
index bbbcad9..ed2cfe9 100644
--- a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.Validate;
 
 /**
  * <p>
@@ -102,12 +103,8 @@ public class DiffBuilder implements Builder<DiffResult> {
     public DiffBuilder(final Object lhs, final Object rhs,
             final ToStringStyle style, final boolean testTriviallyEqual) {
 
-        if (lhs == null) {
-            throw new IllegalArgumentException("lhs cannot be null");
-        }
-        if (rhs == null) {
-            throw new IllegalArgumentException("rhs cannot be null");
-        }
+        Validate.isTrue(lhs != null, "lhs cannot be null");
+        Validate.isTrue(rhs != null, "rhs cannot be null");
 
         this.diffs = new ArrayList<>();
         this.left = lhs;
@@ -167,9 +164,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final boolean lhs,
             final boolean rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -209,9 +204,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final boolean[] lhs,
             final boolean[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
         if (objectsTriviallyEqual) {
             return this;
         }
@@ -250,9 +243,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final byte lhs,
             final byte rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
         if (objectsTriviallyEqual) {
             return this;
         }
@@ -291,9 +282,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final byte[] lhs,
             final byte[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -333,9 +322,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final char lhs,
             final char rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -375,9 +362,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final char[] lhs,
             final char[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -417,9 +402,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final double lhs,
             final double rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -459,9 +442,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final double[] lhs,
             final double[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -501,9 +482,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final float lhs,
             final float rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -543,9 +522,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final float[] lhs,
             final float[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -585,9 +562,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final int lhs,
             final int rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -627,9 +602,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final int[] lhs,
             final int[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -669,9 +642,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final long lhs,
             final long rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -711,9 +682,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final long[] lhs,
             final long[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -753,9 +722,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final short lhs,
             final short rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -795,9 +762,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final short[] lhs,
             final short[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
 
         if (objectsTriviallyEqual) {
             return this;
@@ -837,9 +802,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final Object lhs,
             final Object rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
         if (objectsTriviallyEqual) {
             return this;
         }
@@ -923,9 +886,7 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName, final Object[] lhs,
             final Object[] rhs) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
         if (objectsTriviallyEqual) {
             return this;
         }
@@ -987,12 +948,8 @@ public class DiffBuilder implements Builder<DiffResult> {
      */
     public DiffBuilder append(final String fieldName,
             final DiffResult diffResult) {
-        if (fieldName == null) {
-            throw new IllegalArgumentException("Field name cannot be null");
-        }
-        if (diffResult == null) {
-            throw new IllegalArgumentException("Diff result cannot be null");
-        }
+        validateFieldNameNotNull(fieldName);
+        Validate.isTrue(diffResult != null, "Diff result cannot be null");
         if (objectsTriviallyEqual) {
             return this;
         }
@@ -1019,4 +976,8 @@ public class DiffBuilder implements Builder<DiffResult> {
         return new DiffResult(left, right, diffs, style);
     }
 
+    private void validateFieldNameNotNull(final String fieldName) {
+        Validate.isTrue(fieldName != null, "Field name cannot be null");
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
index 2dbd85e..4bcba6b 100644
--- a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
+++ b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
@@ -20,6 +20,8 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>
  * A {@code DiffResult} contains a collection of the differences between two
@@ -71,18 +73,9 @@ public class DiffResult implements Iterable<Diff<?>> {
      */
     DiffResult(final Object lhs, final Object rhs, final List<Diff<?>> diffs,
             final ToStringStyle style) {
-        if (lhs == null) {
-            throw new IllegalArgumentException(
-                    "Left hand object cannot be null");
-        }
-        if (rhs == null) {
-            throw new IllegalArgumentException(
-                    "Right hand object cannot be null");
-        }
-        if (diffs == null) {
-            throw new IllegalArgumentException(
-                    "List of differences cannot be null");
-        }
+        Validate.isTrue(lhs != null, "Left hand object cannot be null");
+        Validate.isTrue(rhs != null, "Right hand object cannot be null");
+        Validate.isTrue(diffs != null, "List of differences cannot be null");
 
         this.diffs = diffs;
         this.lhs = lhs;

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
index 8511cd7..d68e36b 100644
--- a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
@@ -354,10 +354,7 @@ public class HashCodeBuilder implements Builder<Integer> {
      */
     public static <T> int reflectionHashCode(final int initialNonZeroOddNumber, final int multiplierNonZeroOddNumber, final T object,
             final boolean testTransients, final Class<? super T> reflectUpToClass, final String... excludeFields) {
-
-        if (object == null) {
-            throw new IllegalArgumentException("The object to build a hash code for must not be null");
-        }
+        Validate.isTrue(object != null, "The object to build a hash code for must not be null");
         final HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
         Class<?> clazz = object.getClass();
         reflectionAppend(object, clazz, builder, testTransients, excludeFields);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/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 d40a838..19faa9b 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -27,6 +27,7 @@ import java.util.List;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.ClassUtils;
+import org.apache.commons.lang3.Validate;
 
 /**
  * <p>
@@ -364,9 +365,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     }
     
     private static Object checkNotNull(final Object obj) {
-        if (obj == null) {
-            throw new IllegalArgumentException("The Object passed in should not be null.");
-        }
+        Validate.isTrue(obj != null, "The Object passed in should not be null.");
         return obj;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
index 4363751..20dd748 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ToStringBuilder.java
@@ -17,6 +17,7 @@
 package org.apache.commons.lang3.builder;
 
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.Validate;
 
 /**
  * <p>Assists in implementing {@link Object#toString()} methods.</p>
@@ -132,9 +133,7 @@ public class ToStringBuilder implements Builder<String> {
      * @throws IllegalArgumentException if the style is <code>null</code>
      */
     public static void setDefaultStyle(final ToStringStyle style) {
-        if (style == null) {
-            throw new IllegalArgumentException("The style must not be null");
-        }
+        Validate.isTrue(style != null, "The style must not be null");
         defaultStyle = style;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
index 1941400..c1d0735 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.java
@@ -19,6 +19,8 @@ package org.apache.commons.lang3.concurrent;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>
  * A specialized {@link BackgroundInitializer} implementation that wraps a
@@ -118,8 +120,6 @@ public class CallableBackgroundInitializer<T> extends BackgroundInitializer<T> {
      * @throws IllegalArgumentException if the {@code Callable} is <b>null</b>
      */
     private void checkCallable(final Callable<T> call) {
-        if (call == null) {
-            throw new IllegalArgumentException("Callable must not be null!");
-        }
+        Validate.isTrue(call != null, "Callable must not be null!");
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
index c672538..6a6a9a0 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.java
@@ -23,6 +23,8 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>
  * A specialized {@link BackgroundInitializer} implementation that can deal with
@@ -131,14 +133,8 @@ public class MultiBackgroundInitializer
      * @throws IllegalStateException if {@code start()} has already been called
      */
     public void addInitializer(final String name, final BackgroundInitializer<?> init) {
-        if (name == null) {
-            throw new IllegalArgumentException(
-                    "Name of child initializer must not be null!");
-        }
-        if (init == null) {
-            throw new IllegalArgumentException(
-                    "Child initializer must not be null!");
-        }
+        Validate.isTrue(name != null, "Name of child initializer must not be null!");
+        Validate.isTrue(init != null, "Child initializer must not be null!");
 
         synchronized (this) {
             if (isStarted()) {

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
index 39e270b..63510f0 100644
--- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
+++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
@@ -29,6 +29,7 @@ import java.util.StringTokenizer;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Validate;
 
 /**
  * <p>Provides utilities for manipulating and examining 
@@ -454,9 +455,7 @@ public class ExceptionUtils {
         if (throwable == null) {
             return;
         }
-        if (stream == null) {
-            throw new IllegalArgumentException("The PrintStream must not be null");
-        }
+        Validate.isTrue(stream != null, "The PrintStream must not be null");
         final String trace[] = getRootCauseStackTrace(throwable);
         for (final String element : trace) {
             stream.println(element);
@@ -487,9 +486,7 @@ public class ExceptionUtils {
         if (throwable == null) {
             return;
         }
-        if (writer == null) {
-            throw new IllegalArgumentException("The PrintWriter must not be null");
-        }
+        Validate.isTrue(writer != null, "The PrintWriter must not be null");
         final String trace[] = getRootCauseStackTrace(throwable);
         for (final String element : trace) {
             writer.println(element);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/math/Fraction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/math/Fraction.java b/src/main/java/org/apache/commons/lang3/math/Fraction.java
index 4d5c53f..d4b8ae0 100644
--- a/src/main/java/org/apache/commons/lang3/math/Fraction.java
+++ b/src/main/java/org/apache/commons/lang3/math/Fraction.java
@@ -18,6 +18,8 @@ package org.apache.commons.lang3.math;
 
 import java.math.BigInteger;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p><code>Fraction</code> is a <code>Number</code> implementation that
  * stores fractions accurately.</p>
@@ -313,9 +315,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
      * @throws NumberFormatException if the number format is invalid
      */
     public static Fraction getFraction(String str) {
-        if (str == null) {
-            throw new IllegalArgumentException("The string must not be null");
-        }
+        Validate.isTrue(str != null, "The string must not be null");
         // parse double format
         int pos = str.indexOf('.');
         if (pos >= 0) {
@@ -733,9 +733,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
      *   cannot be represented in an <code>int</code>.
      */
     private Fraction addSub(final Fraction fraction, final boolean isAdd) {
-        if (fraction == null) {
-            throw new IllegalArgumentException("The fraction must not be null");
-        }
+        Validate.isTrue(fraction != null, "The fraction must not be null");
         // zero is identity for addition.
         if (numerator == 0) {
             return isAdd ? fraction : fraction.negate();
@@ -783,9 +781,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
      *  <code>Integer.MAX_VALUE</code>
      */
     public Fraction multiplyBy(final Fraction fraction) {
-        if (fraction == null) {
-            throw new IllegalArgumentException("The fraction must not be null");
-        }
+        Validate.isTrue(fraction != null, "The fraction must not be null");
         if (numerator == 0 || fraction.numerator == 0) {
             return ZERO;
         }
@@ -808,9 +804,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
      *  <code>Integer.MAX_VALUE</code>
      */
     public Fraction divideBy(final Fraction fraction) {
-        if (fraction == null) {
-            throw new IllegalArgumentException("The fraction must not be null");
-        }
+        Validate.isTrue(fraction != null, "The fraction must not be null");
         if (fraction.numerator == 0) {
             throw new ArithmeticException("The fraction to divide by must not be zero");
         }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
index 6d34e62..6142832 100644
--- a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
@@ -37,12 +37,8 @@ public class IEEE754rUtils {
       * @since 3.4 Changed signature from min(double[]) to min(double...)
      */
     public static double min(final double... array) {
-        // Validates input
-        if (array == null) {
-            throw new IllegalArgumentException("The Array must not be null");
-        } 
+        Validate.isTrue(array != null, "The Array must not be null");
         Validate.isTrue(array.length != 0, "Array cannot be empty.");
-        
     
         // Finds and returns min
         double min = array[0];
@@ -63,10 +59,7 @@ public class IEEE754rUtils {
      * @since 3.4 Changed signature from min(float[]) to min(float...)
      */
     public static float min(final float... array) {
-        // Validates input
-        if (array == null) {
-            throw new IllegalArgumentException("The Array must not be null");
-        } 
+        Validate.isTrue(array != null, "The Array must not be null");
         Validate.isTrue(array.length != 0, "Array cannot be empty.");
         
         // Finds and returns min
@@ -156,10 +149,7 @@ public class IEEE754rUtils {
      * @since 3.4 Changed signature from max(double[]) to max(double...)
      */
     public static double max(final double... array) {
-        // Validates input
-        if (array== null) {
-            throw new IllegalArgumentException("The Array must not be null");
-        }         
+        Validate.isTrue(array != null, "The Array must not be null");
         Validate.isTrue(array.length != 0, "Array cannot be empty.");
         
         // Finds and returns max
@@ -181,10 +171,7 @@ public class IEEE754rUtils {
      * @since 3.4 Changed signature from max(float[]) to max(float...)
      */
     public static float max(final float... array) {
-        // Validates input
-        if (array == null) {
-            throw new IllegalArgumentException("The Array must not be null");
-        } 
+        Validate.isTrue(array != null, "The Array must not be null");
         Validate.isTrue(array.length != 0, "Array cannot be empty.");
         
         // Finds and returns max

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index 3dcafac..f77bf10 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -1113,9 +1113,7 @@ public class NumberUtils {
      * @throws IllegalArgumentException if {@code array} is either {@code null} or empty
      */
     private static void validateArray(final Object array) {
-        if (array == null) {
-            throw new IllegalArgumentException("The Array must not be null");
-        }        
+        Validate.isTrue(array != null, "The Array must not be null");
         Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty.");        
     }
      

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ff6b0ada/src/main/java/org/apache/commons/lang3/time/DateUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index 859011a..7f3bc97 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -26,6 +26,8 @@ import java.util.NoSuchElementException;
 import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>A suite of utilities surrounding the use of the
  * {@link java.util.Calendar} and {@link java.util.Date} object.</p>
@@ -511,9 +513,7 @@ public class DateUtils {
      * @throws IllegalArgumentException if the date is null
      */
     private static Date add(final Date date, final int calendarField, final int amount) {
-        if (date == null) {
-            throw new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(date);
         final Calendar c = Calendar.getInstance();
         c.setTime(date);
         c.add(calendarField, amount);
@@ -640,9 +640,7 @@ public class DateUtils {
      * @since 2.4
      */
     private static Date set(final Date date, final int calendarField, final int amount) {
-        if (date == null) {
-            throw new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(date);
         // getInstance() returns a new object, so this method is thread safe.
         final Calendar c = Calendar.getInstance();
         c.setLenient(false);
@@ -708,9 +706,7 @@ public class DateUtils {
      * @throws ArithmeticException if the year is over 280 million
      */
     public static Date round(final Date date, final int field) {
-        if (date == null) {
-            throw new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(date);
         final Calendar gval = Calendar.getInstance();
         gval.setTime(date);
         modify(gval, field, ModifyType.ROUND);
@@ -811,9 +807,7 @@ public class DateUtils {
      * @throws ArithmeticException if the year is over 280 million
      */
     public static Date truncate(final Date date, final int field) {
-        if (date == null) {
-            throw new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(date);
         final Calendar gval = Calendar.getInstance();
         gval.setTime(date);
         modify(gval, field, ModifyType.TRUNCATE);
@@ -891,9 +885,7 @@ public class DateUtils {
      * @since 2.5
      */
     public static Date ceiling(final Date date, final int field) {
-        if (date == null) {
-            throw new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(date);
         final Calendar gval = Calendar.getInstance();
         gval.setTime(date);
         modify(gval, field, ModifyType.CEILING);
@@ -1130,9 +1122,7 @@ public class DateUtils {
      * @throws IllegalArgumentException if the rangeStyle is invalid
      */
     public static Iterator<Calendar> iterator(final Date focus, final int rangeStyle) {
-        if (focus == null) {
-            throw new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(focus);
         final Calendar gval = Calendar.getInstance();
         gval.setTime(focus);
         return iterator(gval, rangeStyle);
@@ -1655,9 +1645,7 @@ public class DateUtils {
      * @since 2.4
      */
     private static long getFragment(final Date date, final int fragment, final TimeUnit unit) {
-        if(date == null) {
-            throw  new IllegalArgumentException("The date must not be null");
-        }
+        validateDateNotNull(date);
         final Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);
         return getFragment(calendar, fragment, unit);
@@ -1794,6 +1782,9 @@ public class DateUtils {
         return truncatedDate1.compareTo(truncatedDate2);
     }
 
+    private static void validateDateNotNull(final Date date) {
+        Validate.isTrue(date != null, "The date must not be null");
+    }
 
     //-----------------------------------------------------------------------
     /**


[34/50] [lang] LANG-1307: Added getDigits method to StringUtils (closes #225)

Posted by br...@apache.org.
LANG-1307: Added getDigits method to StringUtils (closes #225)


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

Branch: refs/heads/release
Commit: 9b3257e4d1a63e0a4d971a331eaf7b9a08d98040
Parents: c8e648b
Author: Arshad Basha <ar...@paypal.com>
Authored: Tue Jan 3 00:14:33 2017 +0530
Committer: pascalschumacher <pa...@gmx.net>
Committed: Mon May 1 11:05:45 2017 +0200

----------------------------------------------------------------------
 .../org/apache/commons/lang3/StringUtils.java   | 36 ++++++++++++++++++++
 .../apache/commons/lang3/StringUtilsTest.java   | 11 ++++++
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9b3257e4/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index bd660bc..6ab1118 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -7157,6 +7157,42 @@ public class StringUtils {
     }
 
     /**
+     * <p>Checks if a String {@code str} contains Unicode digits,
+     * if yes then concatenate all the digits in {@code str} and return it as a String.</p>
+     *
+     * <p>An empty ("") String will be returned if no digits found in {@code str}.</p>
+     *
+     * <pre>
+     * StringUtils.getDigits(null)  = null
+     * StringUtils.getDigits("")    = ""
+     * StringUtils.getDigits("abc") = ""
+     * StringUtils.getDigits("1000$") = "1000"
+     * StringUtils.getDigits("1123~45") = "12345"
+     * StringUtils.getDigits("(541) 754-3010") = "5417543010"
+     * StringUtils.getDigits("\u0967\u0968\u0969") = "\u0967\u0968\u0969"
+     * </pre>
+     *
+     * @param str the String to extract digits from, may be null
+     * @return String with only digits,
+     *           or an empty ("") String if no digits found,
+     *           or {@code null} String if {@code str} is null
+     */
+    public static String getDigits(final String str) {
+        if (isEmpty(str)) {
+            return str;
+        }
+        final int sz = str.length();
+        final StringBuilder strDigits = new StringBuilder(sz);
+        for (int i = 0; i < sz; i++) {
+            final char tempChar = str.charAt(i);
+            if (Character.isDigit(tempChar)) {
+                strDigits.append(tempChar);
+            }
+        }
+        return strDigits.toString();
+    }
+
+    /**
      * <p>Checks if the CharSequence contains only whitespace.</p>
      * 
      * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9b3257e4/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index b776b3b..3051b47 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -3206,4 +3206,15 @@ public class StringUtilsTest {
         assertNull(StringUtils.toCodePoints(null));
         assertArrayEquals(ArrayUtils.EMPTY_INT_ARRAY, StringUtils.toCodePoints(""));
     }
+
+    @Test
+    public void testGetDigits() {
+        assertEquals(null, StringUtils.getDigits(null));
+        assertEquals("", StringUtils.getDigits(""));
+        assertEquals("", StringUtils.getDigits("abc"));
+        assertEquals("1000", StringUtils.getDigits("1000$"));
+        assertEquals("12345", StringUtils.getDigits("123password45"));
+        assertEquals("5417543010", StringUtils.getDigits("(541) 754-3010"));
+        assertEquals("\u0967\u0968\u0969", StringUtils.getDigits("\u0967\u0968\u0969"));
+    }
 }