Replace throw new IOException(..) inside Jackson serializer / deserializer overrides

Apache 2.0

In Jackson 3, serialize() and deserialize() methods no longer declare throws IOException. This recipe removes the throws IOException declaration from overrides of JsonSerializer.serialize, JsonSerializer.serializeWithType, JsonDeserializer.deserialize, and JsonDeserializer.deserializeWithType, and rewrites throw new IOException(msg[, cause]) inside those overrides to JsonMappingException.from(<generator|parser>, msg[, cause]). A companion type change later migrates JsonMappingException to tools.jackson.databind.DatabindException.

org.openrewrite.java.jackson.ReplaceIOExceptionThrowInJacksonOverrides
mod run . --recipe=org.openrewrite.java.jackson.ReplaceIOExceptionThrowInJacksonOverrides

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Remove elements from a method declaration throws clause
  2. Remove elements from a method declaration throws clause