This is an automated email from the ASF dual-hosted git repository.
rjung pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 098de46890 Remove redundant Json escaping of values in
JsonAccessLogValve.
098de46890 is described below
commit 098de4689073e2ef71bba08139239cb6fe4abff6
Author: Rainer Jung <[email protected]>
AuthorDate: Thu Apr 27 10:28:59 2023 +0200
Remove redundant Json escaping of values in JsonAccessLogValve.
The value escaping done in AbstractAccessLogValve is already
Json compliant.
---
.../apache/catalina/valves/JsonAccessLogValve.java | 43 +---------------------
1 file changed, 1 insertion(+), 42 deletions(-)
diff --git a/java/org/apache/catalina/valves/JsonAccessLogValve.java
b/java/org/apache/catalina/valves/JsonAccessLogValve.java
index 4c71278fe9..c7de7a47f0 100644
--- a/java/org/apache/catalina/valves/JsonAccessLogValve.java
+++ b/java/org/apache/catalina/valves/JsonAccessLogValve.java
@@ -17,7 +17,6 @@
package org.apache.catalina.valves;
import java.io.CharArrayWriter;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -140,40 +139,6 @@ public class JsonAccessLogValve extends AccessLogValve {
return new JsonWrappedElement(attributeName, true, ale);
}
- /**
- * JSON string escaping writer
- */
- private static class JsonCharArrayWriter extends CharArrayWriter {
-
- JsonCharArrayWriter(int i) {
- super(i);
- }
-
- @Override
- public void write(int c) {
- try {
- super.write(JSONFilter.escape((char) c));
- } catch (IOException e) {
- // ignore
- }
- }
-
- @Override
- public void write(char[] c, int off, int len) {
- try {
- super.write(JSONFilter.escape(new String(c, off, len)));
- } catch (IOException e) {
- // ignore
- }
- }
-
- @Override
- public void write(String str, int off, int len) {
- CharSequence escaped = JSONFilter.escape(str, off, len);
- super.write(escaped.toString(), 0, escaped.length());
- }
- }
-
private static class JsonWrappedElement implements AccessLogElement,
CachedElement {
private CharSequence attributeName;
@@ -196,13 +161,7 @@ public class JsonAccessLogValve extends AccessLogValve {
if (quoteValue) {
buf.append('"');
}
- CharArrayWriter valueWriter = new JsonCharArrayWriter(8);
- try {
- delegate.addElement(valueWriter, date, request, response,
time);
- valueWriter.writeTo(buf);
- } catch (IOException e) {
- // ignore
- }
+ delegate.addElement(buf, date, request, response, time);
if (quoteValue) {
buf.append('"');
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]