logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1479904 - in /logging/log4j/log4j2/trunk/core/src: main/java/org/apache/logging/log4j/core/config/plugins/ main/java/org/apache/logging/log4j/core/helpers/ main/java/org/apache/logging/log4j/core/net/ test/java/org/apache/logging/log4j/tes...
Date Tue, 07 May 2013 13:32:18 GMT
Author: ggregory
Date: Tue May  7 13:32:17 2013
New Revision: 1479904

URL: http://svn.apache.org/r1479904
Log:
Declare and reuse a public UTF_8 Charset constant in Core. Could be moved to the API module
for re-use by other modules like Flume.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Charsets.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/MimeMessageBuilder.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/layout/BasicLayout.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java?rev=1479904&r1=1479903&r2=1479904&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
Tue May  7 13:32:17 2013
@@ -16,12 +16,6 @@
  */
 package org.apache.logging.log4j.core.config.plugins;
 
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.helpers.Loader;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.wiring.BundleWiring;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -37,6 +31,13 @@ import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.helpers.Charsets;
+import org.apache.logging.log4j.core.helpers.Loader;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.wiring.BundleWiring;
+
 /**
  * <p>ResolverUtil is used to locate classes that are available in the/a class path
and meet
  * arbitrary conditions. The two most common conditions are that a class implements/extends
@@ -239,7 +240,7 @@ public class ResolverUtil {
             try {
                 final URL url = urls.nextElement();
                 String urlPath = url.getFile();
-                urlPath = URLDecoder.decode(urlPath, "UTF-8");
+                urlPath = URLDecoder.decode(urlPath, Charsets.UTF_8.name());
 
                 // If it's a file in a directory, trim the stupid file: spec
                 if (urlPath.startsWith("file:")) {

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Charsets.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Charsets.java?rev=1479904&r1=1479903&r2=1479904&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Charsets.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/Charsets.java
Tue May  7 13:32:17 2013
@@ -24,8 +24,8 @@ import org.apache.logging.log4j.status.S
  * Charset utilities.
  */
 public final class Charsets {
-
-    private static final String UTF_8 = "UTF-8";
+    
+    public static final Charset UTF_8 = Charset.forName("UTF-8");
 
     private Charsets() {
     }
@@ -45,7 +45,7 @@ public final class Charsets {
             }
         }
         if (charset == null) {
-            charset = Charset.forName(UTF_8);
+            charset = UTF_8;
             if (charsetName != null) {
                 StatusLogger.getLogger().error("Charset " + charsetName + " is not supported
for layout, using " +
                     charset.displayName());

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/MimeMessageBuilder.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/MimeMessageBuilder.java?rev=1479904&r1=1479903&r2=1479904&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/MimeMessageBuilder.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/net/MimeMessageBuilder.java
Tue May  7 13:32:17 2013
@@ -23,6 +23,8 @@ import javax.mail.internet.AddressExcept
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
+import org.apache.logging.log4j.core.helpers.Charsets;
+
 /**
  *  Helper class for SMTPManager.
  */
@@ -69,7 +71,7 @@ public class MimeMessageBuilder {
 
     public MimeMessageBuilder setSubject(final String subject) throws MessagingException
{
         if (subject != null) {
-            message.setSubject(subject, "UTF-8");
+            message.setSubject(subject, Charsets.UTF_8.name());
         }
         return this;
     }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/layout/BasicLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/layout/BasicLayout.java?rev=1479904&r1=1479903&r2=1479904&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/layout/BasicLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/test/layout/BasicLayout.java
Tue May  7 13:32:17 2013
@@ -55,7 +55,6 @@ public class BasicLayout extends Abstrac
      */
     @PluginFactory
     public static BasicLayout createLayout() {
-        final Charset charset = Charsets.getSupportedCharset("UTF-8");
-        return new BasicLayout(charset);
+        return new BasicLayout(Charsets.UTF_8);
     }
 }



Mime
View raw message