Skip to content

Commit 9b0326b

Browse files
Victor Uria Vallefrantuma
authored andcommitted
Fix thread safety in Json.mapper() (refs #4672)
1 parent 5fc5d0e commit 9b0326b

File tree

1 file changed

+4
-5
lines changed
  • modules/swagger-core/src/main/java/io/swagger/v3/core/util

1 file changed

+4
-5
lines changed

modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
public class Json {
88

9-
private static ObjectMapper mapper;
9+
private static final class ObjectMapperHolder {
10+
private static final ObjectMapper MAPPER = ObjectMapperFactory.createJson();
11+
}
1012

1113
public static ObjectMapper mapper() {
12-
if (mapper == null) {
13-
mapper = ObjectMapperFactory.createJson();
14-
}
15-
return mapper;
14+
return ObjectMapperHolder.MAPPER;
1615
}
1716

1817
public static ObjectWriter pretty() {

0 commit comments

Comments
 (0)