@Override public Object readFrom(Class serializableClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap headers, InputStream inputStream) throws IOException { DecoderWrapper decoder; if (MediaType.MEDIA_TYPE_WILDCARD.equals(mediaType.getSubtype())) { decoder = xmlDecoder; } else if ("json".equalsIgnoreCase(mediaType.getSubtype())) { decoder = jsonDecoder; } else { decoder = xmlDecoder; // default } try { return decoder.decode(inputStream, serializableClass); } catch (Throwable e) { if (e instanceof Error) { // See issue: https://github.com/Netflix/eureka/issues/72 on why we catch Error here. closeInputOnError(inputStream); throw new WebApplicationException(e, createErrorReply(500, e, mediaType)); } LOGGER.debug("Cannot parse request body", e); throw new WebApplicationException(e, createErrorReply(400, "cannot parse request body", mediaType)); } }
@Override public Object readFrom(Class serializableClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap headers, InputStream inputStream) throws IOException { DecoderWrapper decoder; if (MediaType.MEDIA_TYPE_WILDCARD.equals(mediaType.getSubtype())) { decoder = xmlDecoder; } else if ("json".equalsIgnoreCase(mediaType.getSubtype())) { decoder = jsonDecoder; } else { decoder = xmlDecoder; // default } try { return decoder.decode(inputStream, serializableClass); } catch (Throwable e) { if (e instanceof Error) { // See issue: https://github.com/Netflix/eureka/issues/72 on why we catch Error here. closeInputOnError(inputStream); throw new WebApplicationException(e, createErrorReply(500, e, mediaType)); } LOGGER.debug("Cannot parse request body", e); throw new WebApplicationException(e, createErrorReply(400, "cannot parse request body", mediaType)); } }