SAP / cloud-sdk-java

Use the SAP Cloud SDK for Java to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
22 stars 13 forks source link

Apache5 HttpClient Accessor and Spring Boot 3.1.x #336

Closed alex-de-sap closed 8 months ago

alex-de-sap commented 8 months ago

Issue Description

We are migration our microservices to Spring Boot 3.1.x and Cloud SDK 5.4 We are using Cloud SDK to make http calls via Destinations and Spring Rest Template.

Before Migration (Spring Boot 2.7, Cloud SDK 4.29 ) we did it like this: https://github.wdf.sap.corp/Treasury/tpi-core/blob/master/srv/src/main/java/com/sap/finance/tpi/core/tradingplatformintegration/api360t/Api360tClientPreparationHelperImpl.java

With Spring Boot 3.1 and Cloud SDK 5.4 we think we have to do it somehow like this (described here: https://sap.github.io/cloud-sdk/docs/java/features/connectivity/http-client) https://github.wdf.sap.corp/Treasury/tpi-core/blob/feature/migrate-to-spring-boot-3/srv/src/main/java/com/sap/finance/tpi/core/tradingplatformintegration/api360t/Api360tClientPreparationHelperImpl.java

Issue is that the code described here https://sap.github.io/cloud-sdk/docs/java/features/connectivity/http-client does not fit together:

This gives syntax errors, because DestinationAccessor.getDestination returns com.sap.cloud.sdk.cloudplatform.connectivity.Destination and ApacheHttpClient5Accessor.getHttpClient(destination) expects HttpDestinationProperties

Destination destination = DestinationAccessor.getDestination("my-destination");
HttpClient client = ApacheHttpClient5Accessor.getHttpClient(destination);

Another confusing point is that the apache5 module which should be used is only available in version 4.29.

This leads to the following dependency tree (extract):

[INFO] +- com.sap.cloud.sdk.cloudplatform:scp-cf:jar:5.4.0:compile
[INFO] |  \- com.sap.cloud.sdk:sdk-core:jar:5.4.0:compile
[INFO] |     +- com.sap.cloud.sdk.cloudplatform:connectivity-destination-service:jar:5.4.0:compile
[INFO] |     |  +- com.sap.cloud.sdk.cloudplatform:connectivity-apache-httpclient4:jar:5.4.0:compile
[INFO] |     |  +- com.auth0:java-jwt:jar:4.4.0:compile
[INFO] |     |  \- com.sap.cloud.environment.servicebinding.api:java-consumption-api:jar:0.10.3:compile
[INFO] |     +- com.sap.cloud.sdk.cloudplatform:connectivity-oauth:jar:5.4.0:compile
[INFO] |     +- com.sap.cloud.sdk.cloudplatform:servlet-jakarta:jar:5.4.0:compile
[INFO] |     +- com.sap.cloud.sdk.cloudplatform:tenant:jar:5.4.0:compile
[INFO] |     +- com.sap.cloud.sdk.cloudplatform:security:jar:5.4.0:compile
[INFO] |     \- com.sap.cloud.sdk.cloudplatform:resilience:jar:5.4.0:compile
[INFO] |        +- com.sap.cloud.sdk.cloudplatform:resilience-api:jar:5.4.0:compile
[INFO] |        \- com.sap.cloud.sdk.cloudplatform:resilience4j:jar:5.4.0:compile
[INFO] |           +- io.github.resilience4j:resilience4j-circuitbreaker:jar:2.2.0:compile
[INFO] |           |  \- io.github.resilience4j:resilience4j-core:jar:2.2.0:compile
[INFO] |           +- io.github.resilience4j:resilience4j-bulkhead:jar:2.2.0:compile
[INFO] |           +- io.github.resilience4j:resilience4j-timelimiter:jar:2.2.0:compile
[INFO] |           +- io.github.resilience4j:resilience4j-retry:jar:2.2.0:compile
[INFO] |           +- io.github.resilience4j:resilience4j-ratelimiter:jar:2.2.0:compile
[INFO] |           \- javax.cache:cache-api:jar:1.1.1:compile
[INFO] +- com.sap.cloud.sdk.frameworks:apache-httpclient5:jar:4.29.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:4.29.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:4.29.0:compile
[INFO] |  |  +- com.sap.cloud.environment.servicebinding.api:java-core-api:jar:0.10.1:compile
[INFO] |  |  +- com.sap.cloud.environment.servicebinding.api:java-access-api:jar:0.10.1:compile
[INFO] |  |  +- com.mikesamuel:json-sanitizer:jar:1.2.3:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.16:compile
[INFO] |  |  \- org.bouncycastle:bcpkix-jdk18on:jar:1.77:compile
[INFO] |  |     \- org.bouncycastle:bcutil-jdk18on:jar:1.77:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:caching:jar:4.29.0:compile

Please support by implementing this.

Impact / Priority

Affected development phase: Development

Impact: Blocked

Timeline: n/a

Project Details


Checklist

Johannes-Schneider commented 8 months ago

Hi @alex-de-sap,

thanks for reaching out to us.

I double-checked our documentation and found that everything is indeed correct BUT the link to our Maven module, which provides the ApacheHttpClient5Accessor - the current link is (as you pointed out) currently still suggesting the 4.29.0 module, which is of course incorrect. Instead, you should be using the version 5 variant of the module, which has been renamed for consistency: https://central.sonatype.com/artifact/com.sap.cloud.sdk.cloudplatform/connectivity-apache-httpclient5

By switching to the correct dependency, you will also notice the syntax issues to disappear as we introduced new APIs in SDK 5 to make the overall destination handling and consumption more streamlined.

Please let me know if everything is working out as expected.

Best regards, Johannes