Skip to content

Commit

Permalink
Minor change to exception handling to account for behavioural change in
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Lohan committed Nov 20, 2019
1 parent 688a421 commit a331e75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand Down Expand Up @@ -148,7 +149,8 @@ private Map<String, Object> readMap(Class<?> type, JsonParser p, Deserialization
}
return value;
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new IOException("Can not create empty map for class " + type + " @ " + p.getCurrentLocation(), e);
throw new JsonMappingException(p, "Can not create empty map for class " + type + " @ " + p.getCurrentLocation(),
e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public void testIncorrectJSONException() throws IOException {
});
});
assertThat(ioException.getMessage()).contains("Can not create empty map");
assertThat(ioException.getCause()).isExactlyInstanceOf(NoSuchMethodException.class);

String json = "{\"callGraphs\": {\"foo\": 1, \"bar\": [\"java.util.ArrayList\", [1, 2, 3]]}}";
StdCallbackContext cxt = serializer.deserialize(json, new TypeReference<StdCallbackContext>() {
Expand Down

0 comments on commit a331e75

Please sign in to comment.