Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cloudplatform/security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.sap.cloud.security</groupId>
<artifactId>java-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import javax.annotation.Nonnull;

import org.apache.commons.lang3.StringUtils;

import lombok.Data;

/**
Expand Down Expand Up @@ -34,8 +32,9 @@ public class BearerCredentials implements Credentials
public BearerCredentials( @Nonnull final String token )
{
final String trimmedToken = token.trim();
if( StringUtils.startsWithIgnoreCase(trimmedToken, BEARER_PREFIX) ) {
this.token = trimmedToken.substring(BEARER_PREFIX.length()).trim();
final int l = BEARER_PREFIX.length();
if( trimmedToken.length() > l && trimmedToken.substring(0, l).equalsIgnoreCase(BEARER_PREFIX) ) {
this.token = trimmedToken.substring(l).trim();
} else {
this.token = trimmedToken;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sap.cloud.sdk.datamodel.odata.utility;

import java.util.Collection;
import java.util.Locale;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -120,8 +121,8 @@ public String generateJavaMethodName( @Nonnull final String name )
methodName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, methodName);
methodName = appendSuffixIfNameIsReservedKeyword(methodName, "Objects");

methodName = StringUtils.removeStart(methodName, "to");
methodName = StringUtils.removeStart(methodName, "_");
methodName = removeStartIgnoreCase(methodName, "to");
methodName = removeStartIgnoreCase(methodName, "_");
Copy link
Contributor

@newtork newtork Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we cannot use the suggested new method, since they have just been introduced with their latest update.

That means any "updated" / non-deprecated API would risk a runtime exceptions for users who still use an older version of commons-lang3 with Cloud SDK 5.21.0

Options have been:

  • suppress deprecation warning
  • use suggest new API (incompatibility risk)
  • use custom code to replace deprecated API (I chose this option)

methodName = NamingUtils.uncapitalize(methodName);

throwIfConversionResultIsNullOrEmpty(name, null, methodName, "Java method name");
Expand All @@ -134,8 +135,8 @@ public String generateJavaMethodName( @Nonnull final String name )
public String generateJavaBuilderMethodName( @Nonnull final String name )
{
String methodName = generateNameFromProperty(name, null);
methodName = StringUtils.removeStartIgnoreCase(methodName, "to");
methodName = StringUtils.removeStart(methodName, "_");
methodName = removeStartIgnoreCase(methodName, "to");
methodName = removeStartIgnoreCase(methodName, "_");
methodName = uncapitalizeLeadingAcronym(methodName);
methodName = appendSuffixIfNameIsReservedKeyword(methodName, "Property");

Expand All @@ -152,8 +153,8 @@ public String generateJavaOperationMethodName( @Nonnull final String name, @Null
methodName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, methodName);
methodName = appendSuffixIfNameIsReservedKeyword(methodName, "Function");

methodName = StringUtils.removeStart(methodName, "to");
methodName = StringUtils.removeStart(methodName, "_");
methodName = removeStartIgnoreCase(methodName, "to");
methodName = removeStartIgnoreCase(methodName, "_");

throwIfConversionResultIsNullOrEmpty(name, label, methodName, "Java function import method name");

Expand Down Expand Up @@ -250,7 +251,7 @@ private String removeFirstPrefix( final String name, final Iterable<String> pref
{
String formattedName = name.trim();
for( final String prefixToRemove : prefixes ) {
if( StringUtils.startsWith(formattedName, prefixToRemove) ) {
if( formattedName.startsWith(prefixToRemove) ) {
formattedName = formattedName.substring(prefixToRemove.length());
break;
}
Expand All @@ -262,9 +263,27 @@ private String removeAllSuffixes( @Nonnull final String name, @Nonnull final Ite
{
String formattedName = name;
for( final String suffix : suffixes ) {
formattedName = StringUtils.removeEndIgnoreCase(formattedName, suffix);
formattedName = removeEndIgnoreCase(formattedName, suffix);
}

return formattedName;
}

@Nonnull
private static String removeStartIgnoreCase( @Nonnull final String s, @Nonnull final String prefix )
{
if( s.toLowerCase(Locale.ROOT).startsWith(prefix.toLowerCase(Locale.ROOT)) ) {
return s.substring(prefix.length());
}
return s;
}

@Nonnull
private static String removeEndIgnoreCase( @Nonnull final String s, @Nonnull final String prefix )
{
if( s.toLowerCase(Locale.ROOT).endsWith(prefix.toLowerCase(Locale.ROOT)) ) {
return s.substring(0, s.length() - prefix.length());
}
return s;
}
}
Loading