Hello,
In this application I have followed the FFDC Spring Boot example.
Please find below the environment, Entity, FFDC API Class, and the error stack trace:
I get the error when I try to call addCustomer method from FFDC Api class only (getCustomer works fine).
Please let me know if you need any other details.
====== Environment ======
Java 8
Spring Boot 2.3.3
Spring web
Spring Security Oauth2 2.1.0
httpClient 4.5.9
====== Entity =======
@AllArgsConstructor @NoArgsConstructor @Data @Builder public class FFDCCustomer { //private String id; private String branch; private String country; private String legalName; private String shortName; private String externalId; private String customerStatus; private boolean specialLoan; private boolean restricted; private boolean majorUnderwriter; private LegalAddress legalAddress; }
====== FFDC API =======
@Component public class FfdcApi { @Value("${ffdcapi.baseUrl}") private String baseUrl; @Autowired private OAuth2RestTemplate restTemplate; @Autowired private OAuth2ClientContext oAuth2ClientContext;
public FFDCCustomer getCustomer(String id) { UriComponents uriBuilder = UriComponentsBuilder .fromUriString(baseUrl + "/corporate/lending/customer/v1/customers/" + id) .build(); ResponseEntity<FFDCCustomer> response = restTemplate.exchange(uriBuilder.toUri(), HttpMethod.GET, null, FFDCCustomer.class); return response.getBody(); } public FFDCCustomer addCustomer(FFDCCustomer ffdcCustomer) { UriComponents uriBuilder = UriComponentsBuilder .fromUriString(baseUrl + "/corporate/lending/customer/v1/customers") .build(); ffdcCustomer.setExternalId("92933"); ObjectMapper mapper = new ObjectMapper(); ResponseEntity<FFDCCustomer> response = null; try { HttpHeaders headers = new HttpHeaders(); headers.setBearerAuth(oAuth2ClientContext.getAccessToken().getValue()); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Arrays.asList(MediaType.ALL)); headers.set("Host", baseUrl); String jsonCustomer = mapper.writeValueAsString(ffdcCustomer); HttpEntity<String> requestEntity = new HttpEntity<>(jsonCustomer, headers); response = restTemplate.postForEntity(uriBuilder.toUri(),requestEntity, FFDCCustomer.class); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return response == null ? new FFDCCustomer() : ffdcCustomer; }
}
getCustomer method works without any problem.
addCustomer method throws the below error.
====== Error stack trace =======
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://api.fusionfabric.cloud/corporate/lending/customer/v1/customers": Connection reset; nested exception is javax.net.ssl.SSLException: Connection reset
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:748)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:714)
at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:467)
..
..
..
Caused by: java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:467)
at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:461)
at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1145)
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:832)
Thank you in advance for your help.