commons-lang3 3.13 → 3.13.1 업그레이드와 코드 최적화

- Strings API로 대체 및 StringUtils 불필요 메서드 제거
- CellPhoneValidator 시작 번호 체크 로직 개선
This commit is contained in:
Rinjae
2026-08-18 17:48:58 +09:00
parent 5f5b23026f
commit dfb37c18b9
3 changed files with 12 additions and 15 deletions
@@ -36,6 +36,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@@ -155,10 +156,10 @@ public class ApiSpecService {
updateReferences(pathItem, apiId); updateReferences(pathItem, apiId);
String tmpFullPath = StringUtils.isNotEmpty(basePath) String tmpFullPath = StringUtils.isNotEmpty(basePath)
? StringUtils.join(basePath, "/", StringUtils.removeStart(path, "/")) ? StringUtils.join(basePath, "/", Strings.CS.removeStart(path, "/"))
: path; : path;
final String fullPath = StringUtils.replacePattern(tmpFullPath, "//+", "/"); final String fullPath = tmpFullPath.replaceAll("//+", "/");
// HTTP 메소드별로 중복 체크 // HTTP 메소드별로 중복 체크
pathItem.readOperationsMap().forEach((httpMethod, operation) -> { pathItem.readOperationsMap().forEach((httpMethod, operation) -> {
@@ -294,7 +295,7 @@ public class ApiSpecService {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
Server server = api.getServers().get(0); Server server = api.getServers().get(0);
return StringUtils.removeEnd(server.getUrl(), "/"); return Strings.CS.removeEnd(server.getUrl(), "/");
} }
private void mergeComponents(OpenAPI currentAPI, String apiId, String apiName, Map<String, Object> mergedComponents, ObjectMapper objectMapper) { private void mergeComponents(OpenAPI currentAPI, String apiId, String apiName, Map<String, Object> mergedComponents, ObjectMapper objectMapper) {
@@ -1,6 +1,7 @@
package com.eactive.apim.portal.common.validator; package com.eactive.apim.portal.common.validator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidator;
@@ -39,14 +40,8 @@ public class CellPhoneValidator implements ConstraintValidator<CellPhone, String
} }
// 기존의 prefix 체크 로직 유지 // 기존의 prefix 체크 로직 유지
return StringUtils.startsWith(cellPhone, "+821") || return Strings.CS.startsWithAny(cellPhone,
StringUtils.startsWith(cellPhone, "821") || "+821", "821", "010", "011", "016", "017", "018", "019");
StringUtils.startsWith(cellPhone, "010") ||
StringUtils.startsWith(cellPhone, "011") ||
StringUtils.startsWith(cellPhone, "016") ||
StringUtils.startsWith(cellPhone, "017") ||
StringUtils.startsWith(cellPhone, "018") ||
StringUtils.startsWith(cellPhone, "019");
} }
private boolean isValidPartLength(String prefix, String middle, String last) { private boolean isValidPartLength(String prefix, String middle, String last) {
@@ -11,6 +11,7 @@ import com.eactive.apim.portal.common.util.UserTypeUtil;
import com.eactive.apim.portal.common.validator.CellPhoneValidator; import com.eactive.apim.portal.common.validator.CellPhoneValidator;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -46,21 +47,21 @@ class CommonsLangUpgradeCompatibilityTest {
() -> assertEquals("", StringUtils.trimToEmpty(null)), () -> assertEquals("", StringUtils.trimToEmpty(null)),
() -> assertEquals("api-001", StringUtils.defaultIfBlank(" ", "api-001")), () -> assertEquals("api-001", StringUtils.defaultIfBlank(" ", "api-001")),
() -> assertEquals("API 이름", StringUtils.defaultIfBlank("API 이름", "api-001")), () -> assertEquals("API 이름", StringUtils.defaultIfBlank("API 이름", "api-001")),
() -> assertTrue(StringUtils.equalsAnyIgnoreCase(" Y ".trim(), "true", "y", "1")) () -> assertTrue(Strings.CI.equalsAny(" Y ".trim(), "true", "y", "1"))
); );
} }
@Test @Test
@DisplayName("API 경로와 메시지 리소스명 문자열 처리가 유지된다") @DisplayName("API 경로와 메시지 리소스명 문자열 처리가 유지된다")
void keepsPathAndResourceNameBehavior() { void keepsPathAndResourceNameBehavior() {
String fullPath = StringUtils.join("/openapi/", "/", StringUtils.removeStart("/users", "/")); String fullPath = StringUtils.join("/openapi/", "/", Strings.CS.removeStart("/users", "/"));
String normalizedPath = StringUtils.replacePattern(fullPath, "//+", "/"); String normalizedPath = fullPath.replaceAll("//+", "/");
String resource = "/WEB-INF/messages/messages_ko.properties"; String resource = "/WEB-INF/messages/messages_ko.properties";
String baseName = StringUtils.substringBeforeLast(resource, ".properties"); String baseName = StringUtils.substringBeforeLast(resource, ".properties");
assertAll( assertAll(
() -> assertEquals("/openapi/users", normalizedPath), () -> assertEquals("/openapi/users", normalizedPath),
() -> assertEquals("/openapi", StringUtils.removeEnd("/openapi/", "/")), () -> assertEquals("/openapi", Strings.CS.removeEnd("/openapi/", "/")),
() -> assertEquals("/WEB-INF/messages", StringUtils.substringBeforeLast(baseName, "/")), () -> assertEquals("/WEB-INF/messages", StringUtils.substringBeforeLast(baseName, "/")),
() -> assertEquals("messages_ko", StringUtils.substringAfterLast(baseName, "/")), () -> assertEquals("messages_ko", StringUtils.substringAfterLast(baseName, "/")),
() -> assertEquals("messages", StringUtils.substringBeforeLast("messages_ko", "_")) () -> assertEquals("messages", StringUtils.substringBeforeLast("messages_ko", "_"))