You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/11/21 10:31:26 UTC

logging-log4j2 git commit: LOG4J-1720 Make GelfLayout independent of Jackson

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 5e2a80795 -> 561f9a4f2


LOG4J-1720 Make GelfLayout independent of Jackson


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/561f9a4f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/561f9a4f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/561f9a4f

Branch: refs/heads/master
Commit: 561f9a4f2bb2d001882152ef3be5e8878583478e
Parents: 5e2a807
Author: Mikael St�ldal <mi...@magine.com>
Authored: Mon Nov 21 11:31:17 2016 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Mon Nov 21 11:31:17 2016 +0100

----------------------------------------------------------------------
 .../logging/log4j/core/util/JsonUtils.java      | 39 ++++++++++++++++----
 src/changes/changes.xml                         |  3 ++
 src/site/xdoc/runtime-dependencies.xml          |  4 --
 3 files changed, 35 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/561f9a4f/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
index 74fe079..ae18cc6 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/JsonUtils.java
@@ -16,14 +16,40 @@
  */
 package org.apache.logging.log4j.core.util;
 
-import com.fasterxml.jackson.core.io.CharTypes;
-
 /**
  * This class is borrowed from <a href="https://github.com/FasterXML/jackson-core">Jackson</a>.
  */
 public final class JsonUtils {
 
-    private final static char[] HC = CharTypes.copyHexChars();
+    private static final char[] HC = "0123456789ABCDEF".toCharArray();
+
+    /**
+     * Read-only encoding table for first 128 Unicode code points (single-byte UTF-8 characters).
+     * Value of 0 means "no escaping"; other positive values that value is character
+     * to use after backslash; and negative values that generic (backslash - u)
+     * escaping is to be used.
+     */
+    private static final int[] ESC_CODES;
+    static {
+        int[] table = new int[128];
+        // Control chars need generic escape sequence
+        for (int i = 0; i < 32; ++i) {
+            // 04-Mar-2011, tatu: Used to use "-(i + 1)", replaced with constant
+            table[i] = -1;
+        }
+        /* Others (and some within that range too) have explicit shorter
+         * sequences
+         */
+        table['"'] = '"';
+        table['\\'] = '\\';
+        // Escaping of slash is optional, so let's not add it
+        table[0x08] = 'b';
+        table[0x09] = 't';
+        table[0x0C] = 'f';
+        table[0x0A] = 'n';
+        table[0x0D] = 'r';
+        ESC_CODES = table;
+    }
 
     /**
      * Temporary buffer used for composing quote/escape sequences
@@ -48,8 +74,7 @@ public final class JsonUtils {
      */
     public static void quoteAsString(final CharSequence input, final StringBuilder output) {
         final char[] qbuf = getQBuf();
-        final int[] escCodes = CharTypes.get7BitOutputEscapes();
-        final int escCodeCount = escCodes.length;
+        final int escCodeCount = ESC_CODES.length;
         int inPtr = 0;
         final int inputLen = input.length();
 
@@ -58,7 +83,7 @@ public final class JsonUtils {
             tight_loop:
             while (true) {
                 final char c = input.charAt(inPtr);
-                if (c < escCodeCount && escCodes[c] != 0) {
+                if (c < escCodeCount && ESC_CODES[c] != 0) {
                     break tight_loop;
                 }
                 output.append(c);
@@ -68,7 +93,7 @@ public final class JsonUtils {
             }
             // something to escape; 2 or 6-char variant?
             final char d = input.charAt(inPtr++);
-            final int escCode = escCodes[d];
+            final int escCode = ESC_CODES[d];
             final int length = (escCode < 0)
                     ? _appendNumeric(d, qbuf)
                     : _appendNamed(escCode, qbuf);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/561f9a4f/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6cbc6c9..32459c0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
   </properties>
   <body>
     <release version="2.8" date="2016-MM-DD" description="GA Release 2.8">
+      <action issue="LOG4J2-1720" dev="mikes" type="fix">
+        Make GelfLayout independent of Jackson.
+      </action>
       <action issue="LOG4J2-1719" dev="rpopma" type="fix">
         Fixed race condition in ObjectMessage and SimpleMessage, ensuring that the log message contains the value the object has during the logging call.
       </action>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/561f9a4f/src/site/xdoc/runtime-dependencies.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/runtime-dependencies.xml b/src/site/xdoc/runtime-dependencies.xml
index a60aedb..488b572 100644
--- a/src/site/xdoc/runtime-dependencies.xml
+++ b/src/site/xdoc/runtime-dependencies.xml
@@ -76,10 +76,6 @@
           <td><a href="https://commons.apache.org/proper/commons-csv/">Apache Commons CSV</a></td>
         </tr>
         <tr>
-          <td>GELF Layout</td>
-          <td><a href="https://github.com/FasterXML/jackson">Jackson core</a></td>
-        </tr>
-        <tr>
           <td>JSON Layout</td>
           <td><a href="https://github.com/FasterXML/jackson">Jackson core and databind</a></td>
         </tr>