Skip to content

Commit

Permalink
Assert when used with an unsupported Jackson version
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikurube committed Oct 25, 2023
1 parent 070b89c commit ecf37c3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/embulk/util/json/JsonValueParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
import com.fasterxml.jackson.core.filter.JsonPointerBasedFilter;
import com.fasterxml.jackson.core.filter.TokenFilter;
import com.fasterxml.jackson.core.json.PackageVersion;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -232,6 +233,7 @@ public static Builder builder() {
* @return the new builder
*/
public static Builder builder(final JsonFactory jsonFactory) {
assertJacksonVersion();
return new Builder(jsonFactory);
}

Expand Down Expand Up @@ -267,6 +269,17 @@ public final void close() throws IOException {
this.jacksonParser.close();
}

private static void assertJacksonVersion() {
if (PackageVersion.VERSION.getMajorVersion() != 2) {
throw new UnsupportedOperationException("embulk-util-json is not used with Jackson 2.");
}

final int minor = PackageVersion.VERSION.getMinorVersion();
if (minor < 14 || (minor == 15 && PackageVersion.VERSION.getPatchLevel() <= 2)) {
throw new UnsupportedOperationException("embulk-util-json is not used with Jackson 2.15.3 or later.");
}
}

private final com.fasterxml.jackson.core.JsonParser jacksonParser;
private final InternalJsonValueReader valueReader;

Expand Down

0 comments on commit ecf37c3

Please sign in to comment.