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

DestinationNotFoundException generated when destination is found in CF #486

Closed rvez7 closed 3 months ago

rvez7 commented 3 months ago

Issue Description

The exception com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException with text Could not find environment variable for name 'destinations'. is being raise when destination is found via CF service.

Important information:

Impact / Priority

The outcome is Dynatrace reporting this Exception as top occurrences creating noise to investigate more relevant Exceptions. Slowing down troubleshooting of issues in production by falsely reporting destination errors. Due to long calling stack, generating this exception unnecessarily is expensive memory wise.

Affected development phase: Production

Impact: e.g. Inconvenience

Timeline: Live.

Error Message

Could not find environment variable for name 'destinations'.
com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException

EnvVarDestinationLoader.getJsonNodesJava \| com.sap.cloud.sdk.cloudplatform.connectivity
EnvVarDestinationLoader.extractDestinationJava \| com.sap.cloud.sdk.cloudplatform.connectivity
EnvVarDestinationLoader$$Lambda$.applyJava \| com.sap.cloud.sdk.cloudplatform.connectivity
EnvVarDestinationLoader.lambda$Java \| com.sap.cloud.sdk.cloudplatform.connectivity
EnvVarDestinationLoader$$Lambda$.applyJava \| com.sap.cloud.sdk.cloudplatform.connectivity
Try.ofJava \| io.vavr.control
EnvVarDestinationLoader.tryGetDestinationJava \| com.sap.cloud.sdk.cloudplatform.connectivity
DestinationLoaderChain.tryGetDestinationJava \| com.sap.cloud.sdk.cloudplatform.connectivity 
DestinationLoader.tryGetDestinationJava \| com.sap.cloud.sdk.cloudplatform.connectivity

Project Details


Checklist

MatKuhr commented 3 months ago

Hi @rvez7, you are right, this can be annoying when using tools like Dynatrace that monitor all thrown exceptions. Unfortunately, there is a tradeoff here between a few aspects like usability, error handling, convenience, modularity etc., which lead to the current approach.

You can avoid these exceptions by directly using new DestinationService(), which is the relevant implementation for loading destinations from the BTP Destination Service. However, then you'd have to implement a fallback to env vars manually, in case you are using that e.g. for local testing.