Skip to content

Commit 9797800

Browse files
authored
#patch: make it possible to skip findAndRegisterModules in JacksonSnapshotSerializer (#148)
1 parent c1711a6 commit 9797800

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public DefaultPrettyPrinter withSeparators(Separators separators) {
4949
this.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
5050
this.setSerializationInclusion(JsonInclude.Include.NON_NULL);
5151

52-
this.findAndRegisterModules();
52+
if (shouldFindAndRegisterModules()) {
53+
this.findAndRegisterModules();
54+
}
5355

5456
this.setVisibility(
5557
this.getSerializationConfig()
@@ -69,6 +71,14 @@ public DefaultPrettyPrinter withSeparators(Separators separators) {
6971
*/
7072
public void configure(ObjectMapper objectMapper) {}
7173

74+
/**
75+
* Override to control the registration of all available jackson modules within the classpath
76+
* which are locatable via JDK ServiceLoader facility, along with module-provided SPI.
77+
*/
78+
protected boolean shouldFindAndRegisterModules() {
79+
return true;
80+
}
81+
7282
@Override
7383
public Snapshot apply(Object object, SnapshotSerializerContext gen) {
7484
try {

0 commit comments

Comments
 (0)