diff --git a/src/main/java/io/github/nstdio/http/ext/spi/CompositeJsonMappingProvider.java b/src/main/java/io/github/nstdio/http/ext/spi/CompositeJsonMappingProvider.java index deed74a..3f750f0 100644 --- a/src/main/java/io/github/nstdio/http/ext/spi/CompositeJsonMappingProvider.java +++ b/src/main/java/io/github/nstdio/http/ext/spi/CompositeJsonMappingProvider.java @@ -29,12 +29,20 @@ static boolean hasAnyImplementation() { @Override public JsonMapping get() { if (isJacksonPresent()) { - return new JacksonJsonMapping(); + return JacksonMappingHolder.INSTANCE; } if (isGsonPresent()) { - return new GsonJsonMapping(); + return GsonMappingHolder.INSTANCE; } throw new JsonMappingProviderNotFoundException(NO_JSON_MAPPING_FOUND); } + + private static class JacksonMappingHolder { + private static final JacksonJsonMapping INSTANCE = new JacksonJsonMapping(); + } + + private static class GsonMappingHolder { + private static final GsonJsonMapping INSTANCE = new GsonJsonMapping(); + } }