Skip to content

Commit ecf37c3

Browse files
committed
Assert when used with an unsupported Jackson version
1 parent 070b89c commit ecf37c3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/org/embulk/util/json/JsonValueParser.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
2222
import com.fasterxml.jackson.core.filter.JsonPointerBasedFilter;
2323
import com.fasterxml.jackson.core.filter.TokenFilter;
24+
import com.fasterxml.jackson.core.json.PackageVersion;
2425
import java.io.Closeable;
2526
import java.io.IOException;
2627
import java.io.InputStream;
@@ -232,6 +233,7 @@ public static Builder builder() {
232233
* @return the new builder
233234
*/
234235
public static Builder builder(final JsonFactory jsonFactory) {
236+
assertJacksonVersion();
235237
return new Builder(jsonFactory);
236238
}
237239

@@ -267,6 +269,17 @@ public final void close() throws IOException {
267269
this.jacksonParser.close();
268270
}
269271

272+
private static void assertJacksonVersion() {
273+
if (PackageVersion.VERSION.getMajorVersion() != 2) {
274+
throw new UnsupportedOperationException("embulk-util-json is not used with Jackson 2.");
275+
}
276+
277+
final int minor = PackageVersion.VERSION.getMinorVersion();
278+
if (minor < 14 || (minor == 15 && PackageVersion.VERSION.getPatchLevel() <= 2)) {
279+
throw new UnsupportedOperationException("embulk-util-json is not used with Jackson 2.15.3 or later.");
280+
}
281+
}
282+
270283
private final com.fasterxml.jackson.core.JsonParser jacksonParser;
271284
private final InternalJsonValueReader valueReader;
272285

0 commit comments

Comments
 (0)