Skip to content

Commit

Permalink
Merge pull request #63 from embulk/catch-UnsupportedOperationExceptio…
Browse files Browse the repository at this point in the history
…n-from-toJson

Catch UnsupportedOperationException from toJson
  • Loading branch information
dmikurube authored Nov 9, 2023
2 parents e86d29a + a46470b commit 6cd1a03
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/embulk/util/config/Compat.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ private static Optional<String> callToJsonIfAvailable(final DataSource source) {
jsonStringObject = toJson.invoke(source);
} catch (final InvocationTargetException ex) {
final Throwable targetException = ex.getTargetException();
if (targetException instanceof UnsupportedOperationException) {
// If the plugin's embulk-util-config does not implement toJson, it cannot retrieve a stringified JSON.
return Optional.empty();
}
if (targetException instanceof RuntimeException) {
throw (RuntimeException) targetException;
}
Expand Down

0 comments on commit 6cd1a03

Please sign in to comment.