Skip to content

Commit

Permalink
Remove sofa common util stringutil usage (#332)
Browse files Browse the repository at this point in the history
* Remove unproper usage of StringUtil

Using apache common-langs StringUtils instead of sofa-common-util's StringUtil under profile package, sofa-common-utils's StringUtil under profile package is removed from newer sofa-common-util version.

* Reformat

---------

Co-authored-by: 鲁直 <khotyn.huangt@antgroup.com>
  • Loading branch information
khotyn and 鲁直 authored Jul 8, 2023
1 parent 4d3e142 commit 79ffc04
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.alipay.sofa.registry.server.data.providedata;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.constants.ValueConstants;
import com.alipay.sofa.registry.common.model.metaserver.CompressDatumSwitch;
import com.alipay.sofa.registry.common.model.metaserver.CompressPushSwitch;
Expand All @@ -30,6 +29,7 @@
import com.alipay.sofa.registry.server.shared.providedata.AbstractFetchSystemPropertyService;
import com.alipay.sofa.registry.server.shared.providedata.SystemDataStorage;
import com.alipay.sofa.registry.util.JsonUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

public class CompressDatumService
Expand All @@ -52,7 +52,7 @@ protected int getSystemPropertyIntervalMillis() {
@Override
protected boolean doProcess(CompressStorage expect, ProvideData data) {
final String switchString = ProvideData.toString(data);
if (StringUtil.isBlank(switchString)) {
if (StringUtils.isBlank(switchString)) {
LOGGER.info("Fetch compress datum switch content empty");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.alipay.sofa.registry.server.meta.bootstrap;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.elector.LeaderInfo;
import com.alipay.sofa.registry.common.model.store.URL;
import com.alipay.sofa.registry.log.Logger;
Expand Down Expand Up @@ -178,7 +177,7 @@ public void start() {
"[MetaBootstrap] retry connect to meta leader: {}, client:{}",
leader.getLeader(),
localMetaExchanger.getClient());
return StringUtil.isNotEmpty(leader.getLeader())
return StringUtils.isNotEmpty(leader.getLeader())
&& localMetaExchanger.getClient() != null;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.alipay.sofa.registry.server.meta.remoting.meta;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.store.URL;
import com.alipay.sofa.registry.log.Logger;
import com.alipay.sofa.registry.log.LoggerFactory;
Expand All @@ -33,6 +32,7 @@
import java.util.Collections;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
Expand Down Expand Up @@ -77,12 +77,12 @@ public int getConnNum() {

public Response sendRequest(Object requestBody) throws RequestException {
final String newLeader = metaLeaderService.getLeader();
if (StringUtil.isBlank(newLeader)) {
if (StringUtils.isBlank(newLeader)) {
LOGGER.error("[sendRequest] meta leader is empty.");
return () -> ResultStatus.FAILED;
}

if (!StringUtil.equals(metaLeader, newLeader) || boltExchange.getClient(serverType) == null) {
if (!StringUtils.equals(metaLeader, newLeader) || boltExchange.getClient(serverType) == null) {
setLeaderAndConnect(newLeader);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.alipay.sofa.registry.server.meta.resource;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.CommonResponse;
import com.alipay.sofa.registry.metrics.ReporterUtils;
import com.alipay.sofa.registry.server.meta.MetaLeaderService;
Expand All @@ -33,6 +32,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ private CommonResponse getHealthCheckResult() {
ret = ret && start;
sb.append(", remoteMetaRegisterServerStart:").append(start);

boolean leaderNotEmpty = StringUtil.isNotBlank(metaLeaderService.getLeader());
boolean leaderNotEmpty = StringUtils.isNotBlank(metaLeaderService.getLeader());
ret = ret && leaderNotEmpty;

sb.append(", role:").append(metaLeaderService.amILeader() ? "leader" : "follower");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.alipay.sofa.registry.server.session.providedata;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.constants.ValueConstants;
import com.alipay.sofa.registry.common.model.metaserver.CompressPushSwitch;
import com.alipay.sofa.registry.common.model.metaserver.ProvideData;
Expand Down Expand Up @@ -55,7 +54,7 @@ protected int getSystemPropertyIntervalMillis() {
@Override
protected boolean doProcess(CompressStorage expect, ProvideData data) {
final String switchString = ProvideData.toString(data);
if (StringUtil.isBlank(switchString)) {
if (StringUtils.isBlank(switchString)) {
LOGGER.info("Fetch session push compressed enabled content empty");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
package com.alipay.sofa.registry.server.shared.util;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.console.PersistenceData;
import com.alipay.sofa.registry.store.api.DBResponse;
import com.alipay.sofa.registry.store.api.OperationStatus;
import org.apache.commons.lang.StringUtils;

/**
* @author xiaojian.xj
Expand All @@ -29,7 +29,7 @@ public class PersistenceDataParser {

public static boolean parse2BoolIgnoreCase(
PersistenceData persistenceData, boolean defaultValue) {
if (persistenceData == null || StringUtil.isBlank(persistenceData.getData())) {
if (persistenceData == null || StringUtils.isBlank(persistenceData.getData())) {
return defaultValue;
}
return Boolean.parseBoolean(persistenceData.getData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.alipay.sofa.registry.store.api.elector;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.log.Logger;
import com.alipay.sofa.registry.log.LoggerFactory;
import com.alipay.sofa.registry.net.NetUtil;
Expand All @@ -27,6 +26,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import org.apache.commons.lang.StringUtils;

/**
* @author chen.zhu
Expand Down Expand Up @@ -144,7 +144,7 @@ public boolean amILeader() {
}

protected boolean amILeader(String leader) {
return StringUtil.equals(myself(), leader) && leaderNotExpired();
return StringUtils.equals(myself(), leader) && leaderNotExpired();
}

private boolean leaderNotExpired() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package com.alipay.sofa.registry.jdbc.convertor;

import com.alipay.sofa.common.profile.StringUtil;
import com.alipay.sofa.registry.common.model.store.AppRevision;
import com.alipay.sofa.registry.core.model.AppRevisionInterface;
import com.alipay.sofa.registry.jdbc.domain.AppRevisionDomain;
import com.alipay.sofa.registry.util.JsonUtils;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.annotations.VisibleForTesting;
import java.util.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ public static AppRevision convert2Revision(AppRevisionDomain domain) {
appRevision.setBaseParams(JsonUtils.read(domain.getBaseParams(), BASE_FORMAT));

String serviceParams = domain.getServiceParamsLarge();
if (StringUtil.isBlank(serviceParams)) {
if (StringUtils.isBlank(serviceParams)) {
serviceParams = domain.getServiceParams();
}
appRevision.setInterfaceMap(JsonUtils.read(serviceParams, SERVICE_FORMAT));
Expand Down

0 comments on commit 79ffc04

Please sign in to comment.