Skip to content

Commit

Permalink
Issue #4383 - mark other MultiPartFormInputStream fields as volatile
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Dec 4, 2019
1 parent bb931e4 commit a15e661
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
Expand Up @@ -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
{
Expand Down
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand All @@ -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<Token> tokens = getTokens(formatString);
Collections.reverse(tokens);
Expand Down Expand Up @@ -486,7 +482,7 @@ private static List<Token> 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("!"))
Expand Down Expand Up @@ -581,8 +577,8 @@ private static boolean modify(List<String> modifiers, Boolean negated, StringBui

private MethodHandle updateLogHandle(MethodHandle logHandle, MethodHandle append, MethodHandles.Lookup lookup, String code, String arg, List<String> 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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a15e661

Please sign in to comment.