Skip to content

Commit 82a4db4

Browse files
committed
Assert when used with an unsupported Jackson version
1 parent bc4b8d5 commit 82a4db4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/main/java/org/embulk/util/config/ConfigMapperFactory.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public Builder withValidator(final Validator validator) {
137137
* Creates a {@link Builder} to build {@link ConfigMapperFactory}.
138138
*/
139139
public static Builder builder() {
140+
assertJacksonCoreVersion();
141+
assertJacksonDataBindVersion();
142+
assertJacksonDataTypeJdk8Version();
140143
return new Builder();
141144
}
142145

@@ -320,6 +323,39 @@ private ObjectMapper mapperForOthers() {
320323
return objectMapper;
321324
}
322325

326+
private static void assertJacksonCoreVersion() {
327+
if (com.fasterxml.jackson.core.json.PackageVersion.VERSION.getMajorVersion() != 2) {
328+
throw new UnsupportedOperationException("embulk-util-config is not used with Jackson 2.");
329+
}
330+
331+
final int minor = com.fasterxml.jackson.core.json.PackageVersion.VERSION.getMinorVersion();
332+
if (minor < 14 || (minor == 15 && com.fasterxml.jackson.core.json.PackageVersion.VERSION.getPatchLevel() <= 2)) {
333+
throw new UnsupportedOperationException("embulk-util-config is not used with Jackson 2.15.3 or later.");
334+
}
335+
}
336+
337+
private static void assertJacksonDataBindVersion() {
338+
if (com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION.getMajorVersion() != 2) {
339+
throw new UnsupportedOperationException("embulk-util-config is not used with Jackson 2.");
340+
}
341+
342+
final int minor = com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION.getMinorVersion();
343+
if (minor < 14 || (minor == 15 && com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION.getPatchLevel() <= 2)) {
344+
throw new UnsupportedOperationException("embulk-util-config is not used with Jackson 2.15.3 or later.");
345+
}
346+
}
347+
348+
private static void assertJacksonDataTypeJdk8Version() {
349+
if (com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION.getMajorVersion() != 2) {
350+
throw new UnsupportedOperationException("embulk-util-config is not used with Jackson 2.");
351+
}
352+
353+
final int minor = com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION.getMinorVersion();
354+
if (minor < 14 || (minor == 15 && com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION.getPatchLevel() <= 2)) {
355+
throw new UnsupportedOperationException("embulk-util-config is not used with Jackson 2.15.3 or later.");
356+
}
357+
}
358+
323359
private static final Logger logger = LoggerFactory.getLogger(ConfigMapperFactory.class);
324360

325361
private final List<Module> additionalModules;

0 commit comments

Comments
 (0)