From a15e6614d036eb15c9e32e5d66a8241f9c336a76 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 4 Dec 2019 14:11:34 +1100 Subject: [PATCH] Issue #4383 - mark other MultiPartFormInputStream fields as volatile Signed-off-by: Lachlan Roberts --- .../jetty/http/MultiPartFormInputStream.java | 12 +++++----- .../jetty/server/CustomRequestLog.java | 22 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java index 5984e4470edb..dad32740ab71 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPartFormInputStream.java @@ -64,12 +64,12 @@ public class MultiPartFormInputStream private final MultipartConfigElement _config; private final File _contextTmpDir; private final String _contentType; - private Throwable _err; - private File _tmpDir; - private boolean _deleteOnExit; - private boolean _writeFilesWithFilenames; - private boolean _parsed; - private int _bufferSize = 16 * 1024; + private volatile Throwable _err; + private volatile File _tmpDir; + private volatile boolean _deleteOnExit; + private volatile boolean _writeFilesWithFilenames; + private volatile boolean _parsed; + private volatile int _bufferSize = 16 * 1024; public class MultiPart implements Part { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java index 8135dfbc5b8f..440467211f0c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java @@ -294,11 +294,7 @@ public CustomRequestLog(RequestLog.Writer writer, String formatString) { _logHandle = getLogHandle(formatString); } - catch (NoSuchMethodException e) - { - throw new IllegalStateException(e); - } - catch (IllegalAccessException e) + catch (NoSuchMethodException | IllegalAccessException e) { throw new IllegalStateException(e); } @@ -415,9 +411,9 @@ protected synchronized void doStart() throws Exception if (_ignorePaths != null && _ignorePaths.length > 0) { _ignorePathMap = new PathMappings<>(); - for (int i = 0; i < _ignorePaths.length; i++) + for (String ignorePath : _ignorePaths) { - _ignorePathMap.put(_ignorePaths[i], _ignorePaths[i]); + _ignorePathMap.put(ignorePath, ignorePath); } } else @@ -442,8 +438,8 @@ private static void append(String s, StringBuilder buf) private MethodHandle getLogHandle(String formatString) throws NoSuchMethodException, IllegalAccessException { MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandle append = lookup.findStatic(CustomRequestLog.class, "append", methodType(Void.TYPE, String.class, StringBuilder.class)); - MethodHandle logHandle = lookup.findStatic(CustomRequestLog.class, "logNothing", methodType(Void.TYPE, StringBuilder.class, Request.class, Response.class)); + MethodHandle append = lookup.findStatic(CustomRequestLog.class, "append", methodType(void.class, String.class, StringBuilder.class)); + MethodHandle logHandle = lookup.findStatic(CustomRequestLog.class, "logNothing", methodType(void.class, StringBuilder.class, Request.class, Response.class)); List tokens = getTokens(formatString); Collections.reverse(tokens); @@ -486,7 +482,7 @@ private static List getTokens(String formatString) String arg = m.group("ARG"); String modifierString = m.group("MOD"); - Boolean negated = false; + boolean negated = false; if (modifierString != null) { if (modifierString.startsWith("!")) @@ -581,8 +577,8 @@ private static boolean modify(List modifiers, Boolean negated, StringBui private MethodHandle updateLogHandle(MethodHandle logHandle, MethodHandle append, MethodHandles.Lookup lookup, String code, String arg, List modifiers, boolean negated) throws NoSuchMethodException, IllegalAccessException { - MethodType logType = methodType(Void.TYPE, StringBuilder.class, Request.class, Response.class); - MethodType logTypeArg = methodType(Void.TYPE, String.class, StringBuilder.class, Request.class, Response.class); + MethodType logType = methodType(void.class, StringBuilder.class, Request.class, Response.class); + MethodType logTypeArg = methodType(void.class, String.class, StringBuilder.class, Request.class, Response.class); //TODO should we throw IllegalArgumentExceptions when given arguments for codes which do not take them MethodHandle specificHandle; @@ -832,7 +828,7 @@ else if (arg.equalsIgnoreCase("clf")) DateCache logDateCache = new DateCache(format, locale, timeZone); - MethodType logTypeDateCache = methodType(Void.TYPE, DateCache.class, StringBuilder.class, Request.class, Response.class); + MethodType logTypeDateCache = methodType(void.class, DateCache.class, StringBuilder.class, Request.class, Response.class); specificHandle = lookup.findStatic(CustomRequestLog.class, "logRequestTime", logTypeDateCache); specificHandle = specificHandle.bindTo(logDateCache); break;