Skip to content

Commit d283f4c

Browse files
dependabot[bot]MatKuhrnewtork
authored
chore: bump org.apache.commons:commons-lang3 from 3.17.0 to 3.18.0 in /dependency-bundles/bom (#857)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthias Kuhr <[email protected]> Co-authored-by: Alexander Dümont <[email protected]>
1 parent f4e4284 commit d283f4c

File tree

54 files changed

+330
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+330
-143
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
import javax.annotation.Nonnull;
1212
import javax.annotation.Nullable;
1313

14-
import org.apache.commons.lang3.StringUtils;
15-
1614
import com.google.common.net.HttpHeaders;
1715
import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException;
1816
import com.sap.cloud.sdk.cloudplatform.security.BasicCredentials;
1917
import com.sap.cloud.sdk.cloudplatform.security.BearerCredentials;
2018
import com.sap.cloud.sdk.cloudplatform.security.Credentials;
2119
import com.sap.cloud.sdk.cloudplatform.security.NoCredentials;
20+
import com.sap.cloud.sdk.cloudplatform.util.StringUtils;
2221

2322
import io.vavr.control.Option;
2423
import lombok.extern.slf4j.Slf4j;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import javax.annotation.Nonnull;
66
import javax.annotation.Nullable;
77

8-
import org.apache.commons.lang3.StringUtils;
8+
import com.sap.cloud.sdk.cloudplatform.util.StringUtils;
99

1010
import io.vavr.control.Option;
1111
import lombok.extern.slf4j.Slf4j;

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.sap.cloud.sdk.cloudplatform.connectivity;
22

3+
import static java.util.function.Predicate.not;
4+
35
import java.net.URI;
46
import java.net.URISyntaxException;
57
import java.util.stream.Collectors;
@@ -8,10 +10,9 @@
810
import javax.annotation.Nonnull;
911
import javax.annotation.Nullable;
1012

11-
import org.apache.commons.lang3.StringUtils;
12-
1313
import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationPathsNotMergeableException;
1414
import com.sap.cloud.sdk.cloudplatform.exception.ShouldNotHappenException;
15+
import com.sap.cloud.sdk.cloudplatform.util.StringUtils;
1516

1617
import io.vavr.control.Option;
1718
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +34,7 @@ public class UriPathMerger
3334
* The secondary {@code URI}, usually identifying the request at runtime.
3435
*
3536
* @throws DestinationPathsNotMergeableException
36-
* If either of the request paths of the the given URIs are {@code null} or the URIs differ in the used
37+
* If either of the request paths of the given URIs are {@code null} or the URIs differ in the used
3738
* schema, host, or port.
3839
*
3940
* @return The merged {@code URI}, representing the given request executed on the given destination.
@@ -66,7 +67,7 @@ public URI merge( @Nonnull final URI primaryUri, @Nullable final URI secondaryUr
6667
final String mergeQuery =
6768
Stream
6869
.of(primaryUri.getRawQuery(), secondaryUri.getRawQuery())
69-
.filter(StringUtils::isNotEmpty)
70+
.filter(not(StringUtils::isBlank))
7071
.collect(Collectors.joining("&"));
7172

7273
try {
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
package com.sap.cloud.sdk.cloudplatform.util;
2+
3+
import java.util.Locale;
4+
5+
import javax.annotation.Nonnull;
6+
import javax.annotation.Nullable;
7+
8+
import com.google.common.annotations.Beta;
9+
10+
/**
11+
* Internal utility class for common String operations.
12+
*
13+
* @since 5.21.0
14+
*/
15+
@Beta
16+
public class StringUtils
17+
{
18+
/**
19+
* Checks if the given string starts with the specified prefix, ignoring case.
20+
*
21+
* @param str
22+
* the string to check
23+
* @param prefix
24+
* the prefix to look for
25+
* @return true if the string starts with the prefix, ignoring case; false otherwise
26+
*/
27+
public static boolean startsWithIgnoreCase( @Nullable final String str, @Nullable final String prefix )
28+
{
29+
if( str == null || prefix == null ) {
30+
return false;
31+
}
32+
if( str.length() < prefix.length() ) {
33+
return false;
34+
}
35+
return str.substring(0, prefix.length()).equalsIgnoreCase(prefix);
36+
}
37+
38+
/**
39+
* Checks if the given string ends with the specified suffix, ignoring case.
40+
*
41+
* @param str
42+
* the string to check
43+
* @param suffix
44+
* the suffix to look for
45+
* @return true if the string ends with the suffix, ignoring case; false otherwise
46+
*/
47+
public static boolean endsWithIgnoreCase( @Nullable final String str, @Nullable final String suffix )
48+
{
49+
if( str == null || suffix == null ) {
50+
return false;
51+
}
52+
if( str.length() < suffix.length() ) {
53+
return false;
54+
}
55+
return str.substring(str.length() - suffix.length()).equalsIgnoreCase(suffix);
56+
}
57+
58+
/**
59+
* Removes the specified prefix from the start of the string, ignoring case.
60+
*
61+
* @param s
62+
* the string to modify
63+
* @param prefix
64+
* the prefix to remove
65+
* @return the modified string with the prefix removed, or the original string if it did not start with the prefix;
66+
*/
67+
68+
@Nullable
69+
public static String removeStartIgnoreCase( @Nullable final String s, @Nullable final String prefix )
70+
{
71+
if( startsWithIgnoreCase(s, prefix) ) {
72+
return s.substring(prefix.length());
73+
}
74+
return s;
75+
}
76+
77+
/**
78+
* Removes the specified suffix from the end of the string, ignoring case.
79+
*
80+
* @param s
81+
* the string to modify
82+
* @param prefix
83+
* the suffix to remove
84+
* @return the modified string with the suffix removed, or the original string if it did not end with the suffix;
85+
*/
86+
@Nonnull
87+
public static String removeEndIgnoreCase( @Nonnull final String s, @Nonnull final String prefix )
88+
{
89+
if( endsWithIgnoreCase(s, prefix) ) {
90+
return s.substring(0, s.length() - prefix.length());
91+
}
92+
return s;
93+
}
94+
95+
/**
96+
* Checks if the given string is blank.
97+
*
98+
* @param s
99+
* the string to check
100+
* @return true if the string is null, empty, or contains only whitespace characters; false otherwise
101+
*/
102+
public static boolean isBlank( @Nullable final String s )
103+
{
104+
return isEmpty(s) || s.isBlank();
105+
}
106+
107+
/**
108+
* Checks if the given string is empty.
109+
*
110+
* @param s
111+
* the string to check
112+
* @return true if the string is null, or empty (""); false otherwise
113+
*/
114+
public static boolean isEmpty( @Nullable final String s )
115+
{
116+
return s == null || s.isEmpty();
117+
}
118+
119+
/**
120+
* Checks if the given CharSequence is blank or empty.
121+
*
122+
* @param s
123+
* the CharSequence to check
124+
* @return true if the CharSequence is null, empty, or contains only whitespace characters; false otherwise
125+
*/
126+
public static boolean isBlank( @Nullable final CharSequence s )
127+
{
128+
return s != null && isBlank(s.toString());
129+
}
130+
131+
/**
132+
* Capitalizes the first character of the given string.
133+
*
134+
* @param s
135+
* the string to capitalize
136+
* @return the string with the first character capitalized, or null if the input is null or empty
137+
*/
138+
@Nullable
139+
public static String capitalize( @Nullable final String s )
140+
{
141+
if( s == null || s.isEmpty() ) {
142+
return s;
143+
}
144+
return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1);
145+
}
146+
147+
/**
148+
* Uncapitalizes the first character of the given string.
149+
*
150+
* @param s
151+
* the string to uncapitalize
152+
* @return the string with the first character uncapitalized, or null if the input is null or empty
153+
*/
154+
@Nonnull
155+
public static String uncapitalize( @Nonnull final String s )
156+
{
157+
if( s.isEmpty() ) {
158+
return s;
159+
}
160+
return s.substring(0, 1).toLowerCase(Locale.ROOT) + s.substring(1);
161+
}
162+
163+
/**
164+
* Trims the given string and returns null if the result is empty.
165+
*
166+
* @param s
167+
* the string to trim
168+
* @return the trimmed string, or null if the input is null or empty after trimming
169+
*/
170+
@Nullable
171+
public static String trimToNull( final @Nullable String s )
172+
{
173+
return isBlank(s) ? null : s.trim();
174+
}
175+
176+
/**
177+
* Prepends the specified prefix to the string if it does not already start with that prefix, ignoring case.
178+
*
179+
* @param s
180+
* the string to modify
181+
* @param prefix
182+
* the prefix to prepend
183+
* @return the modified string with the prefix prepended if it was not already present; otherwise, the original
184+
* string
185+
*/
186+
@Nonnull
187+
public static String prependIfMissing( @Nonnull final String s, @Nonnull final String prefix )
188+
{
189+
return startsWithIgnoreCase(s, prefix) ? s : prefix + s;
190+
}
191+
192+
/**
193+
* Returns the substring of the given string before the first occurrence of the specified suffix character.
194+
*
195+
* @param string
196+
* the string to search
197+
* @param suffix
198+
* the character to search for
199+
* @return the substring before the first occurrence of the suffix character, or the original string if the suffix
200+
* is not found;
201+
*/
202+
@Nullable
203+
public static String substringBefore( @Nullable final String string, final char suffix )
204+
{
205+
if( string == null ) {
206+
return null;
207+
}
208+
final int pos = string.indexOf(suffix);
209+
return pos >= 0 ? string.substring(0, pos) : string;
210+
}
211+
}

cloudplatform/connectivity-apache-httpclient4/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@
9696
</exclusion>
9797
</exclusions>
9898
</dependency>
99-
<dependency>
100-
<groupId>org.apache.commons</groupId>
101-
<artifactId>commons-lang3</artifactId>
102-
</dependency>
10399
<!-- scope "provided" -->
104100
<dependency>
105101
<groupId>org.projectlombok</groupId>

cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientWrapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.apache.http.impl.client.CloseableHttpClient;
1717
import org.apache.http.protocol.HttpContext;
1818

19-
import com.google.common.base.Joiner;
2019
import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException;
2120
import com.sap.cloud.sdk.cloudplatform.exception.ShouldNotHappenException;
2221

@@ -114,7 +113,7 @@ public URI mergeRequestUri( @Nonnull final URI requestUri )
114113
final UriPathMerger merger = new UriPathMerger();
115114
final URI mergedUri = merger.merge(destination.getUri(), requestUri);
116115

117-
final String queryString = Joiner.on("&").join(QueryParamGetter.getQueryParameters(destination));
116+
final String queryString = String.join("&", QueryParamGetter.getQueryParameters(destination));
118117
return merger.merge(mergedUri, URI.create("/?" + queryString));
119118
}
120119

cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/QueryParamGetter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
import javax.annotation.Nonnull;
77

8-
import org.apache.commons.lang3.StringUtils;
9-
108
import com.google.common.escape.Escaper;
119
import com.google.common.net.PercentEscaper;
10+
import com.sap.cloud.sdk.cloudplatform.util.StringUtils;
1211

1312
import io.vavr.control.Try;
1413
import lombok.extern.slf4j.Slf4j;

cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/SSLSocketFactoryUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import javax.net.ssl.HostnameVerifier;
99
import javax.net.ssl.SSLContext;
1010

11-
import org.apache.commons.lang3.StringUtils;
1211
import org.apache.http.config.Registry;
1312
import org.apache.http.config.RegistryBuilder;
1413
import org.apache.http.conn.socket.ConnectionSocketFactory;
@@ -18,6 +17,8 @@
1817
import org.apache.http.conn.ssl.NoopHostnameVerifier;
1918
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
2019

20+
import com.sap.cloud.sdk.cloudplatform.util.StringUtils;
21+
2122
import lombok.extern.slf4j.Slf4j;
2223

2324
@Slf4j

cloudplatform/connectivity-apache-httpclient5/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@
8484
<groupId>org.apache.httpcomponents.core5</groupId>
8585
<artifactId>httpcore5</artifactId>
8686
</dependency>
87-
<dependency>
88-
<groupId>org.apache.commons</groupId>
89-
<artifactId>commons-lang3</artifactId>
90-
</dependency>
9187
<!-- scope "provided" -->
9288
<dependency>
9389
<groupId>org.projectlombok</groupId>

cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Wrapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.apache.hc.core5.http.protocol.HttpContext;
1616
import org.apache.hc.core5.io.CloseMode;
1717

18-
import com.google.common.base.Joiner;
1918
import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException;
2019
import com.sap.cloud.sdk.cloudplatform.exception.ShouldNotHappenException;
2120

@@ -103,7 +102,7 @@ ClassicHttpRequest wrapRequest( final ClassicHttpRequest request )
103102
throw new IllegalStateException("Failed to merge destination URI with request URI.", e);
104103
}
105104

106-
final String queryString = Joiner.on("&").join(QueryParamGetter.getQueryParameters(destination));
105+
final String queryString = String.join("&", QueryParamGetter.getQueryParameters(destination));
107106
requestUri = merger.merge(requestUri, URI.create("/?" + queryString));
108107

109108
final ClassicRequestBuilder requestBuilder = ClassicRequestBuilder.copy(request);

0 commit comments

Comments
 (0)