arrowhead-f / core-java

Arrowhead Core Framework Implementation in Java
https://forge.soa4d.org/plugins/mediawiki/wiki/arrowhead-f/index.php/Main_Page
Apache License 2.0
4 stars 12 forks source link

InboundDebugFilter throws exception for incoming request not convertable to JSON format #51

Closed jaivgar closed 5 years ago

jaivgar commented 5 years ago

When creating a service that would consume a MediaType.MULTIPART_FORM_DATA, and executing the system created with the -d option, the incoming request throwed an IOException during JSON serialization: Datamanager_response_error

To avoid the JSON serialization I modified the code in the InboundDebugFilter class like:

if (requestContext.getMediaType() == MediaType.APPLICATION_JSON_TYPE) {
          String prettyJson = Utility.getRequestPayload(requestContext.getEntityStream());
          System.out.println(prettyJson);

          InputStream in = new ByteArrayInputStream(prettyJson.getBytes("UTF-8"));
          requestContext.setEntityStream(in);
}
else {
          // Specify actions for other MediaTypes
}

It was enough for my case but I review could bring a better solution to improve visualization at the command line.

eudyptula commented 5 years ago

I actually manage to find a better solution than checking the media type manually, however this does require a full update to Log4j 2.x.

Fixed in branch: https://github.com/arrowhead-f/core-java/tree/feature/common%2Blog4j2