Skip to content

Commit

Permalink
Use StandardCharsets instead of magic string
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 15, 2023
1 parent 8264a18 commit e589325
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/apache/commons/mail/EmailConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.commons.mail;

import java.nio.charset.StandardCharsets;
import java.time.Duration;

/**
Expand Down Expand Up @@ -70,13 +71,13 @@ public final class EmailConstants {
public static final String KOI8_R = "koi8-r";

/** Charset constant for iso-8859-1 */
public static final String ISO_8859_1 = "iso-8859-1";
public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name();

/** Charset constant for us-ascii */
public static final String US_ASCII = "us-ascii";
public static final String US_ASCII = StandardCharsets.US_ASCII.name();

/** Charset constant for utf-8 */
public static final String UTF_8 = "utf-8";
public static final String UTF_8 = StandardCharsets.UTF_8.name();

/** The debug mode to be used. */
public static final String MAIL_DEBUG = "mail.debug";
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/apache/commons/mail/SimpleEmailTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.apache.commons.mail.mocks.MockSimpleEmail;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -48,7 +49,7 @@ public void testDefaultMimeCharset() throws EmailException, IOException {
* disabling this test as it is dependent on execution order. MimeUtility.getDefaultMIMECharset does some internal caching and if mail.mime.charset is
* not defined, reverts to the default Java charset which is basically the system default file encoding.
*/
System.setProperty(EmailConstants.MAIL_MIME_CHARSET, "utf-8");
System.setProperty(EmailConstants.MAIL_MIME_CHARSET, StandardCharsets.UTF_8.name());
// Test Success
getMailServer();

Expand Down

0 comments on commit e589325

Please sign in to comment.