Отправка исключения в JSON-запрос, содержащий закодированный двоичный файл base 64 с использованием FasterXML / jackson - усеченная строка JSON полезной нагрузки - PullRequest
0 голосов
/ 24 сентября 2018

Я пытаюсь опубликовать двоичный файл в кодировке Base 64 как json, используя следующую логику:

Подход A:

    this.mapper = new ObjectMapper(new JsonFactory().enable(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS));
            final JsonParser parser = mapper.getFactory().createParser(jsonText);

//This next line is failing
            JsonNode jsonNode = mapper.readTree(parser);

Подход B:

//This next line is failing

JsonNode jsonNode = JsonLoader.fromString(jsonText);

Но, не повезло, я получаю:

Неожиданный конец ввода: ожидание закрывающей кавычки для строкового значения Сообщение об исключении: com.fasterxml.jackson.core.io.JsonEOFException

Ниже приведен разрез области его неудачу на:

«base64EncodedFileBinary»: «JVBERi0xLjYNJeLjz9MNCjIzIDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDYxMDE2L08gMjUvRSA1NTQ2OC9OIDEvVCA2MDUwOS9IIFsgNTc2IDE4MV0 + Pg»

строка обрабатывается, когда длина уменьшается, но когда вся строка представляетсядля API это не удается.

Полезная нагрузка усекается после того, как она превышает определенную длину.

Ниже приведена полезная нагрузка, распечатанная при вызове API через Postman:

{
      "a": {
        "b": ["x"],
        "c": {
          "base64EncodedFileBinary": "x",
          "filename": "hello 749 world",
          "mimeType": ["application/pdf"],
          "hash": [{
            "encoding": "SHA256",
            "hash": "x"
          }]
        },
        "x": [
          {
            "base64EncodedFileBinary": "JVBERi0xLjYNJeLjz9MNCjIzIDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDYxMDE2L08gMjUvRSA1NTQ2OC9OIDEvVCA2MDUwOS9IIFsgNTc2IDE4MV0+Pg1lbmRvYmoNICAgICAgICAgICAgICAgICAgDQp4cmVmDQoyMyAxNA0KMDAwMDAwMDAxNiAwMDAwMCBuDQowMDAwMDAwOTI0IDAwMDAwIG4NCjAwMDAwMDExOTcgMDAwMDAgbg0KMDAwMDAwMTQ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mjp8YIisRX1LeGvppfzYgU0_zxS9PCwtcXXL8bcueCCsJ6qAngii_JZVSPDpqT_oT7moZkQ3I17SZIltCsaPm6tkJKR0QaO4aqSPjkkFHWjvxaWCCq0FO7Fr6MwipoLqaus_WXv9NcbCJkVo_aKYT0kCmqr5tRk5aWhCvokqjgWwxpmdH

JSON усекается до того, как он попадает в Json Parser, т.е. в перехватчик

 import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;


    import javax.annotation.Priority;
    import javax.ws.rs.WebApplicationException;
    import javax.ws.rs.container.ResourceInfo;
    import javax.ws.rs.core.Context;
    import javax.ws.rs.ext.Provider;
    import javax.ws.rs.ext.ReaderInterceptor;
    import javax.ws.rs.ext.ReaderInterceptorContext;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import java.io.InputStream;

    @Priority(value = 10)
    @Provider
    public class RestServerReaderInterceptor implements ReaderInterceptor {
        private static final Logger LOG = LoggerFactory.getLogger(RestServerReaderInterceptor.class);

        @Context
        private ResourceInfo resinfo;

        @Override
        public Object aroundReadFrom(ReaderInterceptorContext interceptorContext)
                throws IOException, WebApplicationException {
            InputStream inputStream = interceptorContext.getInputStream();
            byte[] bytes = new byte[inputStream.available()];
            inputStream.read(bytes);
            String requestContent = new String(bytes);
            LOG.info("RestServerReaderInterceptor aroundReadFrom requestContent= "+requestContent);

            try {

// THE JSON IS GETTING TRUNCATED BEFORE GETTING HERE

                if (!resinfo.getResourceMethod().getName().contains("Delete"))
                    new JsonValidator().isJsonValid(requestContent);


            } catch (SchemaValidationFailedException e) {


                throw new WebApplicationException(e);
            }

            LOG.info("RestServerReaderInterceptor aroundReadFrom END ");

            // Need to write back the Input content
            interceptorContext.setInputStream(new ByteArrayInputStream(requestContent.getBytes()));

            return interceptorContext.proceed();
        }
    }

Ответы [ 3 ]

0 голосов
/ 25 сентября 2018

Я не думаю, что ваш код правильно читает поток ввода.Вы выполняете только один вызов чтения и основываете его на значении, возвращаемом доступным.Из документации InputStream.available ()

Неверно использовать возвращаемое значение этого метода для выделения буфера, предназначенного для хранения всех данных в этом потоке.

Если у вас есть доступ к commons-io, вы можете заменить этот код простым IOUtils.toString

или вы можете найти простую реализацию, которая обычно выглядит как-токак

long count = 0; int n; while (-1 != (n = input.read(buffer))) { count += n; } return count;

Этот пример только для иллюстрации, поскольку он ничего не делает с прочитанными данными.Я настоятельно рекомендую вам воспользоваться услугами ИОН, чтобы справиться с этим для вас.Если вы действительно в отчаянии и не можете использовать библиотеку, вы всегда можете обратиться к их источнику напрямую IOUtils , поскольку их лицензия очень разрешительна.

0 голосов
/ 25 сентября 2018

Да, я получил эту работу вчера вечером, заменив:

InputStream inputStream = interceptorContext.getInputStream();
            byte[] bytes = new byte[inputStream.available()];
            inputStream.read(bytes);
            String requestContent = new String(bytes);

на

InputStreamReader reader = new InputStreamReader(interceptorContext.getInputStream(), com.google.common.base.Charsets.UTF_8);
        String requestContent = com.google.common.io.CharStreams.toString(reader);

Унаследованный код (от моего коллеги!) Читал, но обрезал jsonданные.

0 голосов
/ 24 сентября 2018

POST-запросы могут быть сокращены сервером или браузером. Вы уверены, что все сообщение отправлено на ваш десериализатор json?

...