Skip to content

Commit 554f8c7

Browse files
authored
Merge branch 'apache:master' into fix/LANG-1593-join-string-delimiter
2 parents 26f3b05 + a3a0645 commit 554f8c7

File tree

14 files changed

+88
-44
lines changed

14 files changed

+88
-44
lines changed

.github/workflows/maven.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@ jobs:
2424
continue-on-error: ${{ matrix.experimental }}
2525
strategy:
2626
matrix:
27-
#
28-
# Allow Java 16 to fail to allow Java 8 and 11 to run until we know what's wrong on Java 16.
29-
# java: [ 8, 11, 16 ]
30-
java: [ 8, 11 ]
27+
java: [ 8, 11, 17 ]
3128
experimental: [false]
32-
include:
33-
- java: 16
34-
experimental: true
35-
- java: 17-ea
36-
experimental: true
29+
# include:
30+
# - java: 18-ea
31+
# experimental: true
3732
steps:
3833
- uses: actions/checkout@v2.3.4
3934
- uses: actions/cache@v2.1.6

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@
524524
<dependency>
525525
<groupId>org.junit</groupId>
526526
<artifactId>junit-bom</artifactId>
527-
<version>5.7.2</version>
527+
<version>5.8.1</version>
528528
<type>pom</type>
529529
<scope>import</scope>
530530
</dependency>
@@ -632,10 +632,10 @@
632632
<commons.encoding>utf-8</commons.encoding>
633633

634634
<checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
635-
<checkstyle.version>8.45.1</checkstyle.version>
635+
<checkstyle.version>9.0.1</checkstyle.version>
636636
<checkstyle.configdir>src/site/resources/checkstyle</checkstyle.configdir>
637637

638-
<spotbugs.plugin.version>4.3.0</spotbugs.plugin.version>
638+
<spotbugs.plugin.version>4.4.1</spotbugs.plugin.version>
639639
<spotbugs.impl.version>4.2.3</spotbugs.impl.version>
640640
<japicmp.skip>false</japicmp.skip>
641641
<clirr.skip>true</clirr.skip>
@@ -859,7 +859,7 @@
859859
</plugin>
860860
<plugin>
861861
<artifactId>maven-pmd-plugin</artifactId>
862-
<version>3.14.0</version>
862+
<version>3.15.0</version>
863863
<configuration>
864864
<targetJdk>${maven.compiler.target}</targetJdk>
865865
</configuration>

src/changes/changes.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ The <action> type attribute can be add,update,fix,remove.
5858
<action issue="LANG-1670" type="fix" dev="ggregory" due-to="Igor Shuvalov">Fix typos in JavaDoc #795.</action>
5959
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Simplify assertions with equivalent but more simple. #792.</action>
6060
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Avoid multiple equivalent occurrences of the same expression. #797.</action>
61+
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Remove redundant initializers #800.</action>
62+
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Fix ObjectUtils Javadocs #755.</action>
6163
<!-- ADD -->
6264
<action type="add" dev="ggregory" due-to="Gary Gregory">Add EnumUtils.getEnumSystemProperty(...).</action>
6365
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TriConsumer.</action>
@@ -84,20 +86,21 @@ The <action> type attribute can be add,update,fix,remove.
8486
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_16.</action>
8587
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ObjectUtils.identityHashCodeHex(Object).</action>
8688
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ObjectUtils.hashCodeHex(Object).</action>
89+
<action type="add" dev="ggregory" due-to="Gary Gregory">Add StringUtils.removeStart(String, char).</action>
8790
<!-- UPDATE -->
88-
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3 #735.</action>
91+
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.4.1 #735, #808.</action>
8992
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess">Bump Bump actions/cache from v2.1.4 to v2.1.6 #742, #752, #764.</action>
9093
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump actions/setup-java from v1.4.3 to v2.</action>
91-
<action type="update" dev="ggregory" due-to="Dependabot">Bump spotbugs-maven-plugin from 4.2.2 to 4.3.0.</action>
9294
<action type="update" dev="ggregory" due-to="Dependabot">Bump spotbugs from 4.2.2 to 4.2.3 #744.</action>
93-
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump checkstyle from 8.41 to 8.45.1 #739, #768, #787.</action>
95+
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump checkstyle from 8.41 to 9.0.1 #739, #768, #787, #811.</action>
9496
<action type="update" dev="ggregory" due-to="Dependabot">Bump easymock from 4.2 to 4.3 #746.</action>
9597
<action type="update" dev="ggregory" due-to="Gary Gregory">commons.jacoco.version 0.8.6 -> 0.8.7.</action>
9698
<action type="update" dev="ggregory" due-to="Gary Gregory">commons.japicmp.version 0.15.2 -> 0.15.3.</action>
9799
<action type="update" dev="ggregory" due-to="Dependabot">Bump junit-pioneer from 1.3.8 to 1.4.2 #749, #767.</action>
98-
<action type="update" dev="ggregory" due-to="Dependabot">Bump junit-bom from 5.7.1 to 5.7.2 #761.</action>
100+
<action type="update" dev="ggregory" due-to="Dependabot">Bump junit-bom from 5.7.1 to 5.8.1 #761, #805, #807.</action>
99101
<action type="update" dev="ggregory" due-to="Dependabot">Bump commons.javadoc.version from 3.2.0 to 3.3.0.</action>
100102
<action type="update" dev="ggregory" due-to="Dependabot">Bump jmh.version from 1.27 to 1.33 #794.</action>
103+
<action type="update" dev="ggregory" due-to="Dependabot">Bump maven-pmd-plugin from 3.14.0 to 3.15.0 #802.</action>
101104
</release>
102105

103106
<release version="3.12.0" date="2021-02-26" description="New features and bug fixes (Java 8).">

src/main/java/org/apache/commons/lang3/ArrayUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ public static short[] add(final short[] array, final short element) {
764764
*/
765765
@Deprecated
766766
public static <T> T[] add(final T[] array, final int index, final T element) {
767-
Class<T> clss = null;
767+
Class<T> clss;
768768
if (array != null) {
769769
clss = getComponentType(array);
770770
} else if (element != null) {
@@ -4285,7 +4285,7 @@ public static int lastIndexOf(final short[] array, final short valueToFind, int
42854285
* @param componentType The array class.
42864286
* @param length the array length
42874287
* @return The new array.
4288-
* @exception NullPointerException if the specified {@code componentType} parameter is null.
4288+
* @throws NullPointerException if the specified {@code componentType} parameter is null.
42894289
* @since 3.13.0
42904290
*/
42914291
@SuppressWarnings("unchecked") // OK, because array and values are of type T

src/main/java/org/apache/commons/lang3/CharSetUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static String squeeze(final String str, final String... set) {
212212
final char[] chrs = str.toCharArray();
213213
final int sz = chrs.length;
214214
char lastChar = chrs[0];
215-
char ch = ' ';
215+
char ch;
216216
Character inChars = null;
217217
Character notInChars = null;
218218
buffer.append(lastChar);

src/main/java/org/apache/commons/lang3/ObjectUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -819,8 +819,8 @@ public static int hashCodeMulti(final Object... objects) {
819819
* will throw a NullPointerException for either of the two parameters. </p>
820820
*
821821
* <pre>
822-
* ObjectUtils.identityToString(appendable, "") = appendable.append("java.lang.String@1e23"
823-
* ObjectUtils.identityToString(appendable, Boolean.TRUE) = appendable.append("java.lang.Boolean@7fa"
822+
* ObjectUtils.identityToString(appendable, "") = appendable.append("java.lang.String@1e23")
823+
* ObjectUtils.identityToString(appendable, Boolean.TRUE) = appendable.append("java.lang.Boolean@7fa")
824824
* ObjectUtils.identityToString(appendable, Boolean.TRUE) = appendable.append("java.lang.Boolean@7fa")
825825
* </pre>
826826
*
@@ -887,8 +887,8 @@ public static String identityToString(final Object object) {
887887
* will throw a NullPointerException for either of the two parameters. </p>
888888
*
889889
* <pre>
890-
* ObjectUtils.identityToString(builder, "") = builder.append("java.lang.String@1e23"
891-
* ObjectUtils.identityToString(builder, Boolean.TRUE) = builder.append("java.lang.Boolean@7fa"
890+
* ObjectUtils.identityToString(builder, "") = builder.append("java.lang.String@1e23")
891+
* ObjectUtils.identityToString(builder, Boolean.TRUE) = builder.append("java.lang.Boolean@7fa")
892892
* ObjectUtils.identityToString(builder, Boolean.TRUE) = builder.append("java.lang.Boolean@7fa")
893893
* </pre>
894894
*
@@ -915,8 +915,8 @@ public static void identityToString(final StrBuilder builder, final Object objec
915915
* will throw a NullPointerException for either of the two parameters. </p>
916916
*
917917
* <pre>
918-
* ObjectUtils.identityToString(buf, "") = buf.append("java.lang.String@1e23"
919-
* ObjectUtils.identityToString(buf, Boolean.TRUE) = buf.append("java.lang.Boolean@7fa"
918+
* ObjectUtils.identityToString(buf, "") = buf.append("java.lang.String@1e23")
919+
* ObjectUtils.identityToString(buf, Boolean.TRUE) = buf.append("java.lang.Boolean@7fa")
920920
* ObjectUtils.identityToString(buf, Boolean.TRUE) = buf.append("java.lang.Boolean@7fa")
921921
* </pre>
922922
*
@@ -940,8 +940,8 @@ public static void identityToString(final StringBuffer buffer, final Object obje
940940
* will throw a NullPointerException for either of the two parameters. </p>
941941
*
942942
* <pre>
943-
* ObjectUtils.identityToString(builder, "") = builder.append("java.lang.String@1e23"
944-
* ObjectUtils.identityToString(builder, Boolean.TRUE) = builder.append("java.lang.Boolean@7fa"
943+
* ObjectUtils.identityToString(builder, "") = builder.append("java.lang.String@1e23")
944+
* ObjectUtils.identityToString(builder, Boolean.TRUE) = builder.append("java.lang.Boolean@7fa")
945945
* ObjectUtils.identityToString(builder, Boolean.TRUE) = builder.append("java.lang.Boolean@7fa")
946946
* </pre>
947947
*

src/main/java/org/apache/commons/lang3/StringUtils.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,7 +2816,7 @@ public static int indexOfAny(final CharSequence str, final CharSequence... searc
28162816
// String's can't have a MAX_VALUEth index.
28172817
int ret = Integer.MAX_VALUE;
28182818

2819-
int tmp = 0;
2819+
int tmp;
28202820
for (final CharSequence search : searchStrs) {
28212821
if (search == null) {
28222822
continue;
@@ -5506,7 +5506,7 @@ public static int lastIndexOfAny(final CharSequence str, final CharSequence... s
55065506
return INDEX_NOT_FOUND;
55075507
}
55085508
int ret = INDEX_NOT_FOUND;
5509-
int tmp = 0;
5509+
int tmp;
55105510
for (final CharSequence search : searchStrs) {
55115511
if (search == null) {
55125512
continue;
@@ -6585,6 +6585,36 @@ public static String removePattern(final String source, final String regex) {
65856585
return RegExUtils.removePattern(source, regex);
65866586
}
65876587

6588+
/**
6589+
* Removes a char only if it is at the beginning of a source string,
6590+
* otherwise returns the source string.
6591+
*
6592+
* <p>A {@code null} source string will return {@code null}.
6593+
* An empty ("") source string will return the empty string.
6594+
* A {@code null} search char will return the source string.</p>
6595+
*
6596+
* <pre>
6597+
* StringUtils.removeStart(null, *) = null
6598+
* StringUtils.removeStart("", *) = ""
6599+
* StringUtils.removeStart(*, null) = *
6600+
* StringUtils.removeStart("/path", '/') = "path"
6601+
* StringUtils.removeStart("path", '/') = "path"
6602+
* StringUtils.removeStart("path", 0) = "path"
6603+
* </pre>
6604+
*
6605+
* @param str the source String to search, may be null.
6606+
* @param remove the char to search for and remove.
6607+
* @return the substring with the char removed if found,
6608+
* {@code null} if null String input.
6609+
* @since 3.13.0
6610+
*/
6611+
public static String removeStart(final String str, final char remove) {
6612+
if (isEmpty(str)) {
6613+
return str;
6614+
}
6615+
return str.charAt(0) == remove ? str.substring(1) : str;
6616+
}
6617+
65886618
/**
65896619
* <p>Removes a substring only if it is at the beginning of a source string,
65906620
* otherwise returns the source string.</p>
@@ -7163,7 +7193,7 @@ private static String replaceEach(
71637193
// index on index that the match was found
71647194
int textIndex = -1;
71657195
int replaceIndex = -1;
7166-
int tempIndex = -1;
7196+
int tempIndex;
71677197

71687198
// index of replace array that will replace the search string found
71697199
// NOTE: logic duplicated below START

src/main/java/org/apache/commons/lang3/math/Fraction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ public static Fraction getFraction(double value) {
257257
int denom0 = 1; // the pre-previous
258258
int numer1 = 1; // the previous
259259
int denom1 = 0; // the previous
260-
int numer2 = 0; // the current, setup in calculation
261-
int denom2 = 0; // the current, setup in calculation
260+
int numer2; // the current, setup in calculation
261+
int denom2; // the current, setup in calculation
262262
int a1 = (int) value;
263-
int a2 = 0;
263+
int a2;
264264
double x1 = 1;
265-
double x2 = 0;
265+
double x2;
266266
double y1 = value - a1;
267-
double y2 = 0;
267+
double y2;
268268
double delta1, delta2 = Double.MAX_VALUE;
269269
double fraction;
270270
int i = 1;

src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public static Object invokeMethod(final Object object, final boolean forceAccess
209209
args = ArrayUtils.nullToEmpty(args);
210210

211211
final String messagePrefix;
212-
Method method = null;
212+
Method method;
213213

214214
if (forceAccess) {
215215
messagePrefix = "No such method: ";

src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ private static Type getClosestParentType(final Class<?> cls, final Class<?> supe
630630

631631
// find the interface closest to the super class
632632
for (final Type midType : interfaceTypes) {
633-
Class<?> midClass = null;
633+
Class<?> midClass;
634634

635635
if (midType instanceof ParameterizedType) {
636636
midClass = getRawType((ParameterizedType) midType);

0 commit comments

Comments
 (0)