devonfw / devon4j

devonfw Java stack - create enterprise-grade business apps in Java safe and fast
Apache License 2.0
83 stars 87 forks source link

#284: support for synchronous rest client using http client #410

Closed hohwille closed 3 years ago

hohwille commented 3 years ago

Implementation of issue #284 (synchronous service client via HttpClient) and replacement for PR #401.

For the record: due to the refactoring, I changed some internal classes and methods. The public usage API remains unchanged but in case some project hooked in deeply to override code my changes could potentially break something. I doubt that anybody would do this from outside without getting in touch so IMHO all fine.

hohwille commented 3 years ago

For the record: @ssarmokadam is testing this feature and will give feedback till end of this week so I plan to merge and release on monday.

hohwille commented 3 years ago

@ssarmokadam found a stupid bug I made during the refactoring in her manual tests of the archetype that I fixed with https://github.com/devonfw/devon4j/pull/410/commits/93f6ff98531d60aa206639bb176f95e059353c5c

hohwille commented 3 years ago

Also we wanted to follow opt-in approach for archetype rather than opt-out. Therefore in the core module of the archetype I...

hohwille commented 3 years ago

For the record: @ssarmokadam made a manual test and found a bug using such REST operation:

@GET
  @Path("/clientrequest/")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public String returnResponseToClient(String args);

Call this worked via CXF client but failed with HttpClient with:

aused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (String)""; line: 1, column: 0]
    at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.12.2.jar:2.12.2]

It turned out that the content-type was expected but missing. I therefore fixed the MediaType/ContentType handling in my last commit: https://github.com/devonfw/devon4j/pull/410/commits/db6abd71287796103719a5bcbd50c07a6d534c5c

@ssarmokadam confirmed that my last commit fixes the problem. Therefore I consider this PR as tested and ready to merge now.