Skip to content

Commit a331e75

Browse files
author
Ryan Lohan
committed
Minor change to exception handling to account for behavioural change in FasterXML/jackson-databind#1675
1 parent 688a421 commit a331e75

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/software/amazon/cloudformation/proxy/StdCallbackContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.fasterxml.jackson.core.JsonToken;
2222
import com.fasterxml.jackson.databind.DeserializationContext;
2323
import com.fasterxml.jackson.databind.JsonDeserializer;
24+
import com.fasterxml.jackson.databind.JsonMappingException;
2425
import com.fasterxml.jackson.databind.JsonSerializer;
2526
import com.fasterxml.jackson.databind.SerializerProvider;
2627
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@@ -148,7 +149,8 @@ private Map<String, Object> readMap(Class<?> type, JsonParser p, Deserialization
148149
}
149150
return value;
150151
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
151-
throw new IOException("Can not create empty map for class " + type + " @ " + p.getCurrentLocation(), e);
152+
throw new JsonMappingException(p, "Can not create empty map for class " + type + " @ " + p.getCurrentLocation(),
153+
e);
152154
}
153155
}
154156

src/test/java/software/amazon/cloudformation/proxy/StdCallackContextTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ public void testIncorrectJSONException() throws IOException {
236236
});
237237
});
238238
assertThat(ioException.getMessage()).contains("Can not create empty map");
239+
assertThat(ioException.getCause()).isExactlyInstanceOf(NoSuchMethodException.class);
239240

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

0 commit comments

Comments
 (0)