Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-182

HTTPJsonResponseHandler fails on JSONArray: JsonMappingException

    XMLWordPrintable

Details

    • CP: Non-roadmap backlog
    • Core: Platform

    Description

      HTTPJsonResponseHandler.handleSuccess("[]", response) fails with this Exception:

      com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token
       at [Source: java.io.StringReader@492fc9c2; line: 1, column: 1]
              at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
              at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:575)
              at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:569)
              at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:310)
              at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
              at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
              at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
              at io.vertx.core.json.Json.decodeValue(Json.java:79)
              at io.vertx.core.json.JsonObject.fromJson(JsonObject.java:930)
              at io.vertx.core.json.JsonObject.<init>(JsonObject.java:53)
              at io.vertx.core.buffer.impl.BufferImpl.toJsonObject(BufferImpl.java:82)
              at org.folio.rest.tools.client.HTTPJsonResponseHandler.handleSuccess(HTTPJsonResponseHandler.java:100)
      

      Please catch all exceptions (not only DecodeException), and consider returning this JsonObject

      {"array":"[…]"}

      if the buffer contains some JsonArray (use bh.toJsonArray()).

      In addition consider r.body = new JsonObject().put("wrapped_text", bh.getByteBuf().toString(StandardCharsets.UTF_8)); to correctly mask quotes and the like and to use UTF_8 instead of some server charset.

      TestRail: Results

        Attachments

          Activity

            People

              Unassigned Unassigned
              julianladisch Julian Ladisch
              Julian Ladisch Julian Ladisch
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                TestRail: Runs

                  TestRail: Cases