Skip to content

Commit e8464dd

Browse files
chore: Switch error logging to throwing an exception for OnPrem conne… (#364)
Co-authored-by: Charles Dubois <[email protected]> Co-authored-by: I538344 <[email protected]>
1 parent 624b943 commit e8464dd

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpDestination.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -1004,15 +1004,7 @@ public DefaultHttpDestination build()
10041004
return proxyHandler.handle(this);
10051005
}
10061006
catch( final Exception e ) {
1007-
final String msg =
1008-
"""
1009-
Unable to resolve proxy configuration for destination. \
1010-
This destination cannot be used for anything other than reading its properties. \
1011-
This is unexpected and will be changed to fail instead in a future version of Cloud SDK. \
1012-
Please analyze the attached stack trace and resolve the issue. \
1013-
In case only the properties of a destination should be accessed, without performing authorization flows, please use the 'getDestinationProperties' method on 'DestinationService' instead.\
1014-
""";
1015-
log.error(msg, e);
1007+
throw new DestinationAccessException("Unable to resolve proxy configuration for destination", e);
10161008
}
10171009
}
10181010
return buildInternal();

cloudplatform/cloudplatform-connectivity/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpDestinationTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ void testProxyConfigurationOverwritesExistingProperties()
530530
.property(DestinationProperty.PROXY_HOST, "initial.host")
531531
.property(DestinationProperty.PROXY_PORT, 4321)
532532
.property(DestinationProperty.PROXY_AUTH, "Bearer initial-token")
533-
.property(DestinationProperty.PROXY_TYPE, ProxyType.ON_PREMISE)
534533
.build();
535534

536535
final ProxyConfiguration proxyConfiguration =
@@ -549,7 +548,6 @@ void testProxyConfigurationOverwritesExistingProperties()
549548
assertThat(destination.get(DestinationProperty.PROXY_URI))
550549
.containsExactly(URI.create("http://overwritten.uri:5678"));
551550
assertThat(destination.get(DestinationProperty.PROXY_AUTH)).containsExactly("Bearer overwritten-token");
552-
assertThat(destination.get(DestinationProperty.PROXY_TYPE)).containsExactly(ProxyType.ON_PREMISE);
553551
// "fallback" properties ARE NOT overwritten - this is done for compatibility with Cloud SDK v4 behavior
554552
assertThat(destination.get(DestinationProperty.PROXY_HOST)).containsExactly("initial.host");
555553
assertThat(destination.get(DestinationProperty.PROXY_PORT)).containsExactly(4321);

cloudplatform/cloudplatform-connectivity/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/EnvVarDestinationLoaderTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void testProxyTypeUncommonSpelling()
196196
{
197197
"type": "HTTP",
198198
"name": "%s",
199-
"proxyType": "onpremise",
199+
"proxyType": "Internet",
200200
"description": "This destination rocks!",
201201
"authentication": "BasicAuthentication"
202202
"URL": "https://URL",
@@ -218,7 +218,7 @@ void testProxyTypeUncommonSpelling()
218218
final HttpDestination httpDestination = destination.asHttp();
219219

220220
final Option<ProxyType> proxyType = httpDestination.getProxyType();
221-
assertThat(proxyType.get()).isEqualTo(ProxyType.ON_PREMISE);
221+
assertThat(proxyType.get()).isEqualTo(ProxyType.INTERNET);
222222
}
223223

224224
@Test
@@ -230,7 +230,7 @@ void testAdditionalProperty()
230230
{
231231
"type": "HTTP",
232232
"name": "%s",
233-
"proxyType": "onpremise",
233+
"proxyType": "Internet",
234234
"description": "This destination rocks!",
235235
"authentication": "BasicAuthentication"
236236
"URL": "https://URL",
@@ -312,7 +312,7 @@ void testFallbackPropertyKeys()
312312
{
313313
"type": "HTTP",
314314
"name": "%s",
315-
"proxyType": "onpremise",
315+
"proxyType": "Internet",
316316
"description": "This destination rocks!",
317317
"URL": "https://URL",
318318
"username": "USER",

cloudplatform/connectivity-oauth/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2ServiceBindingDestinationLoaderTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void testProxiedDestination()
352352
{
353353
final URI proxyUrl = URI.create("http://proxyUrl:1234");
354354
final DefaultHttpDestination baseDestination =
355-
DefaultHttpDestination.builder(baseUrl).proxyType(ProxyType.ON_PREMISE).build();
355+
DefaultHttpDestination.builder(baseUrl).proxyType(ProxyType.ON_PREMISE).buildInternal();
356356

357357
final DestinationHeaderProvider headerProviderMock = mock(DestinationHeaderProvider.class);
358358
when(headerProviderMock.getHeaders(any())).thenReturn(Collections.emptyList());
@@ -460,7 +460,7 @@ void testSkipProxyTokenRetrieval()
460460
{
461461
final URI proxyUrl = URI.create("http://proxyUrl:1234");
462462
final DefaultHttpDestination baseDestination =
463-
DefaultHttpDestination.builder(baseUrl).proxyType(ProxyType.ON_PREMISE).build();
463+
DefaultHttpDestination.builder(baseUrl).proxyType(ProxyType.ON_PREMISE).buildInternal();
464464
final ServiceBindingDestinationOptions options =
465465
ServiceBindingDestinationOptions
466466
.forService(EMPTY_BINDING)

release_notes.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
- CAP `com.sap.cds` 2.9.3
1414
- SAP Java Buildpack `com.sap.cloud.sjb` 2.10.0
1515
- Using IAS requires XSUAA version to be minimum `3.4.0`.
16+
- Change the `DefaultHttpDestination.Builder` to throw an exception when the proxy configuration can not be determined for on-premise destinations.
17+
Previously, only an error was logged to give a grace period for analyzing and fixing the underlying issue.
1618

1719
### ✨ New Functionality
1820

0 commit comments

Comments
 (0)