{"record":{"id":"9116baaf442d9b23","repo":"eclipse-vertx/vert.x","slug":"e-getmessage","errorCode":null,"errorMessage":"${e.getMessage()}","messagePattern":"\\$\\{e\\.getMessage\\(\\)\\}","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/parsetools/impl/JsonEventImpl.java","lineNumber":99,"sourceCode":"    return type == JsonEventType.VALUE && value == null;\n  }\n\n  @Override\n  public boolean isObject() {\n    return value instanceof JsonObject;\n  }\n\n  @Override\n  public boolean isArray() {\n    return value instanceof JsonArray;\n  }\n\n  @Override\n  public <T> T mapTo(Class<T> type) {\n    try {\n      return JacksonFactory.CODEC.fromValue(value, type);\n    } catch (Exception e) {\n      throw new DecodeException(e.getMessage(), e);\n    }\n  }\n\n  @Override\n  public Integer integerValue() {\n    if (value != null) {\n      Number number = (Number) value;\n      if (value instanceof Integer) {\n        return (Integer)value;  // Avoids unnecessary unbox/box\n      } else {\n        return number.intValue();\n      }\n    }\n    return null;\n  }\n\n  @Override\n  public Long longValue() {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/parsetools/impl/JsonEventImpl.java#L81-L117","documentation":"JsonEvent.mapTo converts the event's parsed JSON value into the given Java class using the Jackson databind codec. If Jackson cannot map the value (missing properties, wrong shape, type mismatch), the exception is rethrown as a DecodeException whose message is the underlying failure's message. It signals that the JSON does not conform to the target type.","triggerScenarios":"Mapping a JSON object to a POJO whose required properties are missing or of incompatible types; mapping a non-object value to a class; unknown properties when the mapper is configured to fail on them.","commonSituations":"Deserializing JSON event streams into DTOs during JSON-RPC or NDJSON processing; schema drift between producer and consumer; numbers-as-strings vs numbers type mismatches.","solutions":["Inspect the DecodeException message to find the Jackson failure and fix the JSON or target class","Annotate the target class with @JsonIgnoreProperties(ignoreUnknown = true) or configure the ObjectMapper to be lenient","Validate the event shape (e.g. check isObject/fieldNames) before calling mapTo"],"exampleFix":"// before\nUser u = event.mapTo(User.class); // DecodeException on shape mismatch\n// after\nif (event.type() == JsonEventType.OBJECT) {\n  try {\n    User u = event.mapTo(User.class);\n  } catch (DecodeException e) {\n    log.warn(\"Bad payload: {}\", e.getMessage());\n  }\n}","handlingStrategy":"try-catch","validationCode":"if (event.type() != JsonEventType.OBJECT || !event.fieldNames().containsAll(requiredFields)) {\n  throw new DecodeException(\"Event does not match expected shape\");\n}","typeGuard":"boolean isObjectEvent(JsonEvent e) {\n  return e.type() == JsonEventType.OBJECT;\n}","tryCatchPattern":"try {\n  User u = event.mapTo(User.class);\n} catch (DecodeException e) {\n  // log e.getMessage(); reject or skip the event\n}","preventionTips":["Match the target class to the actual JSON shape; keep DTOs tolerant with @JsonIgnoreProperties","Validate event type/fields before mapTo","Cover mapping with tests using real producer payloads"],"tags":["vertx","json","decode-exception","databind"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}