This is an automated email from the ASF dual-hosted git repository. rjung pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new ad0177cfbb Switch from lambda to new parametrized CharElement. ad0177cfbb is described below commit ad0177cfbb29dd1751bb612327f52b6e188bd116 Author: Rainer Jung <rainer.j...@kippdata.de> AuthorDate: Thu Apr 27 10:08:55 2023 +0200 Switch from lambda to new parametrized CharElement. It is more consistent with all other output and eases backports. --- .../apache/catalina/valves/JsonAccessLogValve.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/valves/JsonAccessLogValve.java b/java/org/apache/catalina/valves/JsonAccessLogValve.java index 2a56d1763e..bd4fb91da4 100644 --- a/java/org/apache/catalina/valves/JsonAccessLogValve.java +++ b/java/org/apache/catalina/valves/JsonAccessLogValve.java @@ -93,11 +93,27 @@ public class JsonAccessLogValve extends AccessLogValve { PATTERNS = Collections.unmodifiableMap(pattern2AttributeName); } + /** + * write any char + */ + protected static class CharElement implements AccessLogElement { + private final char ch; + + public CharElement(char ch) { + this.ch = ch; + } + + @Override + public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time) { + buf.write(ch); + } + } + @Override protected AccessLogElement[] createLogElements() { List<AccessLogElement> logElements = new ArrayList<>(Arrays.asList(super.createLogElements())); ListIterator<AccessLogElement> lit = logElements.listIterator(); - lit.add((buf, date, req, resp, time) -> buf.write('{')); + lit.add(new CharElement('{')); while (lit.hasNext()) { AccessLogElement logElement = lit.next(); // remove all other elements, like StringElements @@ -105,12 +121,12 @@ public class JsonAccessLogValve extends AccessLogValve { lit.remove(); continue; } - lit.add((buf, date, req, resp, time) -> buf.write(',')); + lit.add(new CharElement(',')); } // remove last comma again lit.previous(); lit.remove(); - lit.add((buf, date, req, resp, time) -> buf.write('}')); + lit.add(new CharElement('}')); return logElements.toArray(new AccessLogElement[logElements.size()]); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org