diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java index 84c318fd62..899c7476ed 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java @@ -6,13 +6,12 @@ public class Json { - private static ObjectMapper mapper; + private static final class ObjectMapperHolder { + private static final ObjectMapper MAPPER = ObjectMapperFactory.createJson(); + } public static ObjectMapper mapper() { - if (mapper == null) { - mapper = ObjectMapperFactory.createJson(); - } - return mapper; + return ObjectMapperHolder.MAPPER; } public static ObjectWriter pretty() {