This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-net.git
commit 6609491ea0cb2923dcb5427f8e04d1c5d7b0b989 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue May 28 07:38:28 2024 -0400 Deprecate org.apache.commons.net.util.Charsets.Charsets() for removal --- src/changes/changes.xml | 1 + src/main/java/org/apache/commons/net/util/Charsets.java | 12 +++++++++++- src/test/java/org/apache/commons/net/util/CharsetsTest.java | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 97501f01..07cc58fe 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -72,6 +72,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory">Guard against polynomial regular expression used on uncontrolled data in IMAPReply.UNTAGGED_RESPONSE.</action> <action type="fix" issue="NET-730" dev="ggregory" due-to="Johannes Thalmair, Gary Gregory">Cannot connect to FTP server with HTTP proxy.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Base 64 Encoding with URL and Filename Safe Alphabet should not chunk per RFC 4648.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate org.apache.commons.net.util.Charsets.Charsets() for removal.</action> <!-- ADD --> <action type="add" issue="NET-726" dev="ggregory" due-to="PJ Fanning, Gary Gregory">Add protected getters to FTPSClient #204.</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add SubnetUtils.toString().</action> diff --git a/src/main/java/org/apache/commons/net/util/Charsets.java b/src/main/java/org/apache/commons/net/util/Charsets.java index 290b7ec7..14e3429d 100644 --- a/src/main/java/org/apache/commons/net/util/Charsets.java +++ b/src/main/java/org/apache/commons/net/util/Charsets.java @@ -35,7 +35,7 @@ public class Charsets { public static Charset toCharset(final String charsetName) { return charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName); } - + /** * Returns a charset object for the given charset name. * @@ -47,4 +47,14 @@ public class Charsets { public static Charset toCharset(final String charsetName, final String defaultCharsetName) { return charsetName == null ? Charset.forName(defaultCharsetName) : Charset.forName(charsetName); } + + /** + * Depreacted. + * + * @deprecated Will be removed in 2.0. + */ + @Deprecated + public Charsets() { + // empty + } } diff --git a/src/test/java/org/apache/commons/net/util/CharsetsTest.java b/src/test/java/org/apache/commons/net/util/CharsetsTest.java index 6db3b512..3f9b9df9 100644 --- a/src/test/java/org/apache/commons/net/util/CharsetsTest.java +++ b/src/test/java/org/apache/commons/net/util/CharsetsTest.java @@ -17,6 +17,7 @@ package org.apache.commons.net.util; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import java.nio.charset.StandardCharsets; @@ -33,6 +34,12 @@ public class CharsetsTest { assertEquals(StandardCharsets.UTF_8, Charsets.toCharset(StandardCharsets.UTF_8.name())); } + @SuppressWarnings("deprecation") + @Test + public void testToConstructor() { + assertDoesNotThrow(Charsets::new); + } + @Test public void testToCharsetDefault() { assertEquals(StandardCharsets.UTF_8, Charsets.toCharset(null, StandardCharsets.UTF_8.name()));