Skip to content

Commit

Permalink
fixed issue “json minify class is not thread safe, leads to errors on…
Browse files Browse the repository at this point in the history
  • Loading branch information
ujibang committed Feb 17, 2017
1 parent 4af1045 commit 8309af9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* @author Andrea Di Cesare {@literal <[email protected]>}
*/
public class ResponseSenderHandler extends PipedHttpHandler {

/**
* @param next
*/
Expand Down Expand Up @@ -95,7 +94,7 @@ public void handleRequest(
}
}

if (context.getRepresentationFormat()
if (context.getRepresentationFormat()
== RequestContext.REPRESENTATION_FORMAT.HAL) {
exchange.getResponseHeaders().put(
Headers.CONTENT_TYPE, Representation.HAL_JSON_MEDIA_TYPE);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/restheart/utils/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,15 @@ public static boolean checkType(Optional<BsonValue> o, String type) {
}
}

private static Minify minifier = new Minify();

/**
* @param jsonString
* @return minified json string
*/
public static String minify(String jsonString) {
// Minify is not thread safe. don to declare as static object
// see https://softinstigate.atlassian.net/browse/RH-233
Minify minifier = new Minify();

if (true) {
return minifier.minify(jsonString);
}
Expand Down

0 comments on commit 8309af9

Please sign in to comment.