Skip to content

Commit

Permalink
fix(api): Fix JsonMessage asynchronous methods don't catch all poss…
Browse files Browse the repository at this point in the history
…ible thrown exceptions during decoding
  • Loading branch information
fussel178 authored and Ludwig Richter committed Mar 23, 2022
1 parent 8f78d07 commit d40074e
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public interface JsonMessage {
* @return {@code true} when the conversion was successful
*/
static <T extends JsonMessage> boolean on(Class<T> type, Buffer json, Handler<T> handler,
Handler<DecodeException> exceptionHandler) {
Handler<RuntimeException> exceptionHandler) {
try {
handler.handle(from(json, type));
return true;
} catch (DecodeException e) {
} catch (DecodeException | IllegalArgumentException e) {
logger.warn("Cannot convert buffer to JsonMessage {}:", type.getName(), e);
exceptionHandler.handle(e);
return false;
Expand All @@ -73,11 +73,11 @@ static <T extends JsonMessage> boolean on(Class<T> type, Buffer json, Handler<T>
* @return {@code true} when the conversion was successful
*/
static <T extends JsonMessage> boolean on(Class<T> type, String json, Handler<T> handler,
Handler<DecodeException> exceptionHandler) {
Handler<RuntimeException> exceptionHandler) {
try {
handler.handle(from(json, type));
return true;
} catch (DecodeException e) {
} catch (DecodeException | IllegalArgumentException e) {
logger.warn("Cannot convert JSON string to JsonMessage {}:", type.getName(), e);
exceptionHandler.handle(e);
return false;
Expand All @@ -96,11 +96,11 @@ static <T extends JsonMessage> boolean on(Class<T> type, String json, Handler<T>
* @return {@code true} when the conversion was successful
*/
static <T extends JsonMessage> boolean on(Class<T> type, Object json, Handler<T> handler,
Handler<DecodeException> exceptionHandler) {
Handler<RuntimeException> exceptionHandler) {
try {
handler.handle(from(json, type));
return true;
} catch (DecodeException e) {
} catch (DecodeException | IllegalArgumentException e) {
logger.warn("Cannot convert Object to JsonMessage {}:", type.getName(), e);
exceptionHandler.handle(e);
return false;
Expand All @@ -119,11 +119,11 @@ static <T extends JsonMessage> boolean on(Class<T> type, Object json, Handler<T>
* @return {@code true} when the conversion was successful
*/
static <T extends JsonMessage> boolean on(Class<T> type, Message<?> message, Handler<T> handler,
Handler<DecodeException> exceptionHandler) {
Handler<RuntimeException> exceptionHandler) {
try {
handler.handle(from(message, type));
return true;
} catch (DecodeException e) {
} catch (DecodeException | IllegalArgumentException e) {
logger.warn("Cannot convert Vertx Message to JsonMessage {}:", type.getName(), e);
exceptionHandler.handle(e);
return false;
Expand Down

0 comments on commit d40074e

Please sign in to comment.