From 36c6d12416f20c0d7012bd92379a2a96ed8ca066 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 25 Sep 2024 14:59:09 -0400 Subject: [PATCH 1/4] Make default constructor private --- src/main/java/org/apache/commons/lang3/Strings.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/apache/commons/lang3/Strings.java b/src/main/java/org/apache/commons/lang3/Strings.java index edca2c0a2..c982f3794 100644 --- a/src/main/java/org/apache/commons/lang3/Strings.java +++ b/src/main/java/org/apache/commons/lang3/Strings.java @@ -36,6 +36,13 @@ public abstract class Strings { */ public static class Builder extends AbstractSupplier { + /** + * Constructs a new instance. + */ + private Builder() { + // empty + } + /** * Ignores case when possible. */ From de0a20b5ab73697fd5d01369952fa2a5bc892384 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 25 Sep 2024 15:14:25 -0400 Subject: [PATCH 2/4] Pick Java EE Javadoc URL from parent POM This will fix the Java 23 Javadoc generation when commons-parent 76 is out --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 496eff197..3154e728c 100644 --- a/pom.xml +++ b/pom.xml @@ -223,7 +223,7 @@ true https://commons.apache.org/proper/commons-text/apidocs - https://docs.oracle.com/javaee/6/api + ${commons.javadoc.javaee.link} true @@ -328,7 +328,7 @@ true https://commons.apache.org/proper/commons-text/apidocs - https://docs.oracle.com/javaee/6/api + ${commons.javadoc.javaee.link} true From a4d35b8204f89d2c436f941ff4eaa40bca8b6ac9 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 25 Sep 2024 18:31:44 -0400 Subject: [PATCH 3/4] Sort members --- .../java/org/apache/commons/lang3/Strings.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/Strings.java b/src/main/java/org/apache/commons/lang3/Strings.java index c982f3794..f775b3ae7 100644 --- a/src/main/java/org/apache/commons/lang3/Strings.java +++ b/src/main/java/org/apache/commons/lang3/Strings.java @@ -36,13 +36,6 @@ public abstract class Strings { */ public static class Builder extends AbstractSupplier { - /** - * Constructs a new instance. - */ - private Builder() { - // empty - } - /** * Ignores case when possible. */ @@ -53,6 +46,13 @@ public abstract class Strings { */ private boolean nullIsLess; + /** + * Constructs a new instance. + */ + private Builder() { + // empty + } + /** * Gets a new {@link Strings} instance. */ From 5a9d81b0a40cbf52083b722f900af541850d8c47 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 25 Sep 2024 18:35:31 -0400 Subject: [PATCH 4/4] Use try-with-resources --- .../commons/lang3/text/StrBuilderTest.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java index 198cefd10..e771622c1 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -146,38 +146,39 @@ public class StrBuilderTest extends AbstractLangTest { @Test public void testAsReader() throws Exception { final StrBuilder sb = new StrBuilder("some text"); - Reader reader = sb.asReader(); - assertTrue(reader.ready()); - final char[] buf = new char[40]; - assertEquals(9, reader.read(buf)); - assertEquals("some text", new String(buf, 0, 9)); + try (Reader reader = sb.asReader()) { + assertTrue(reader.ready()); + final char[] buf = new char[40]; + assertEquals(9, reader.read(buf)); + assertEquals("some text", new String(buf, 0, 9)); - assertEquals(-1, reader.read()); - assertFalse(reader.ready()); - assertEquals(0, reader.skip(2)); - assertEquals(0, reader.skip(-1)); + assertEquals(-1, reader.read()); + assertFalse(reader.ready()); + assertEquals(0, reader.skip(2)); + assertEquals(0, reader.skip(-1)); - assertTrue(reader.markSupported()); - reader = sb.asReader(); - assertEquals('s', reader.read()); - reader.mark(-1); + assertTrue(reader.markSupported()); + } char[] array = new char[3]; - assertEquals(3, reader.read(array, 0, 3)); - assertEquals('o', array[0]); - assertEquals('m', array[1]); - assertEquals('e', array[2]); - reader.reset(); - assertEquals(1, reader.read(array, 1, 1)); - assertEquals('o', array[0]); - assertEquals('o', array[1]); - assertEquals('e', array[2]); - assertEquals(2, reader.skip(2)); - assertEquals(' ', reader.read()); - - assertTrue(reader.ready()); - reader.close(); - assertTrue(reader.ready()); + try (Reader reader = sb.asReader()) { + assertEquals('s', reader.read()); + reader.mark(-1); + assertEquals(3, reader.read(array, 0, 3)); + assertEquals('o', array[0]); + assertEquals('m', array[1]); + assertEquals('e', array[2]); + reader.reset(); + assertEquals(1, reader.read(array, 1, 1)); + assertEquals('o', array[0]); + assertEquals('o', array[1]); + assertEquals('e', array[2]); + assertEquals(2, reader.skip(2)); + assertEquals(' ', reader.read()); + assertTrue(reader.ready()); + reader.close(); + assertTrue(reader.ready()); + } try (Reader r = sb.asReader()) { final char[] arr = new char[3]; assertThrows(IndexOutOfBoundsException.class, () -> r.read(arr, -1, 0));