diff options
author | vasraz <vasyl.razinkov@est.tech> | 2019-11-20 17:32:02 +0000 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-11-25 08:21:43 +0000 |
commit | 60be4e21f1ada02fbbdb39cc47ff1c69c098a00a (patch) | |
tree | 8d05c95e8b856255564fd6f9f1e1c096f77b5567 | |
parent | fe540e1d6e3f0155741a4b4bc48f5ec56f114852 (diff) |
Fix Sonar issue
Major SmellCode:
Replace StringBuffer with StringBuilder
Change-Id: I0283e5160e5c1f23423c66110015f18c8163411e
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-2670
13 files changed, 28 insertions, 28 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java index de19d09319..33cf9d46da 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java @@ -134,7 +134,7 @@ public class ArtifactValidatorExecuter{ try { // "service name, service id, state, version for(Component component: components ){ - StringBuffer sb = new StringBuffer(component.getName()); + StringBuilder sb = new StringBuilder(component.getName()); sb.append(",").append(component.getUniqueId()).append(",").append(component.getInvariantUUID()).append(",").append(component.getLifecycleState()).append(",").append(component.getVersion()); sb.append("\n"); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index fd2af0bb7c..040c460ffc 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -1828,7 +1828,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { String newValue, Component containerComponent, ComponentInstance foundResourceInstance, String capabilityType, String capabilityName) { String componentInstanceUniqueId = foundResourceInstance.getUniqueId(); - StringBuffer sb = new StringBuffer(componentInstanceUniqueId); + StringBuilder sb = new StringBuilder(componentInstanceUniqueId); sb.append(ModelConverter.CAP_PROP_DELIM).append(property.getOwnerId()).append(ModelConverter.CAP_PROP_DELIM) .append(capabilityType).append(ModelConverter.CAP_PROP_DELIM).append(capabilityName); String capKey = sb.toString(); @@ -1858,7 +1858,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } else { propOwner = foundResourceInstance.getSourceModelUid(); } - StringBuffer sb = new StringBuffer(componentInstanceUniqueId); + StringBuilder sb = new StringBuilder(componentInstanceUniqueId); sb.append(ModelConverter.CAP_PROP_DELIM).append(propOwner).append(ModelConverter.CAP_PROP_DELIM) .append(capabilityType).append(ModelConverter.CAP_PROP_DELIM).append(capabilityName); diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java index 591d7f32d7..f679a5c103 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java @@ -1246,16 +1246,16 @@ public class JanusGraphGenericDao { public JanusGraphOperationStatus lockElement(String id, NodeTypeEnum type) { - StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX); + StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX); lockId.append(type.getName()).append("_").append(id); return lockNode(lockId.toString()); } public JanusGraphOperationStatus lockElement(GraphNode node) { - StringBuffer lockId = createLockElementId(node); + String lockId = createLockElementId(node); - return lockNode(lockId.toString()); + return lockNode(lockId); } private JanusGraphOperationStatus lockNode(String lockId) { @@ -1416,12 +1416,12 @@ public class JanusGraphGenericDao { * @return */ public JanusGraphOperationStatus releaseElement(GraphNode node) { - StringBuffer lockId = createLockElementId(node); + String lockId = createLockElementId(node); return unlockNode(lockId); } - private JanusGraphOperationStatus unlockNode(StringBuffer lockId) { + private JanusGraphOperationStatus unlockNode(String lockId) { GraphNodeLock lockNode = new GraphNodeLock(lockId.toString()); Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class); @@ -1437,15 +1437,15 @@ public class JanusGraphGenericDao { } public JanusGraphOperationStatus releaseElement(String id, NodeTypeEnum type) { - StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX); + StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX); lockId.append(type.getName()).append("_").append(id); - return unlockNode(lockId); + return unlockNode(lockId.toString()); } - private StringBuffer createLockElementId(GraphNode node) { - StringBuffer lockId = new StringBuffer(LOCK_NODE_PREFIX); + private String createLockElementId(GraphNode node) { + StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX); lockId.append(node.getLabel()).append("_").append(node.getUniqueId()); - return lockId; + return lockId.toString(); } public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) { diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java index 2d2d9b8962..acd6969a71 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java @@ -28,7 +28,7 @@ public class IdBuilderUtils { private static String DOT = "."; public static String generateChildId(String componentId, VertexTypeEnum type){ - StringBuffer sb = new StringBuffer(componentId); + StringBuilder sb = new StringBuilder(componentId); sb.append(DOT).append(type.getName()); return sb.toString(); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java index ab08f5c339..d5e0675203 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java @@ -1365,7 +1365,7 @@ public class ToscaOperationFacade { propOwner = fetchedCIOptional.get().getSourceModelUid(); } StorageOperationStatus status; - StringBuffer sb = new StringBuffer(componentInstanceId); + StringBuilder sb = new StringBuilder(componentInstanceId); sb.append(ModelConverter.CAP_PROP_DELIM).append(propOwner).append(ModelConverter.CAP_PROP_DELIM) .append(capabilityDefinition.getType()).append(ModelConverter.CAP_PROP_DELIM).append(capabilityDefinition.getName()); String capKey = sb.toString(); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java index 390e27ee0b..9c9194828e 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java @@ -211,7 +211,7 @@ public class NodeTemplateOperationGraphTest extends ModelTestBase{ } private String buildInstanceId(int originIndex, int insIndex) { - StringBuffer sb = new StringBuffer("instanceId_"); + StringBuilder sb = new StringBuilder("instanceId_"); sb.append(originIndex).append("-").append(insIndex); return sb.toString(); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java index 6633148485..988f215a72 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java @@ -383,7 +383,7 @@ public class ValidationUtils { public static String normaliseComponentName(String name) { String[] split = splitComponentName(name); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (String splitElement : split) { sb.append(splitElement); } @@ -393,7 +393,7 @@ public class ValidationUtils { public static String normalizeComponentInstanceName(String name) { String[] split = splitComponentInstanceName(name); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (String splitElement : split) { sb.append(splitElement); } @@ -415,7 +415,7 @@ public class ValidationUtils { public static String convertToSystemName(String name) { String[] split = splitComponentName(name); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (String splitElement : split) { String capitalize = WordUtils.capitalize(splitElement); sb.append(capitalize); @@ -531,7 +531,7 @@ public class ValidationUtils { public static String normaliseProductName(String name) { String[] split = splitComponentName(PRODUCT_NAME_DELIMETER_PATTERN, name); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (String splitElement : split) { sb.append(splitElement); } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java index 9806bffc5e..fadb9d47aa 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java @@ -475,7 +475,7 @@ public class CommonUtilsTest { @Test public void yamlValidTest() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("key: \"!@;/?:&=+$,_.~*'()[]\""); byte[] payload = sb.toString().getBytes(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java index 56502757de..fd1703bfcb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java @@ -153,7 +153,7 @@ public class CsarUtilsTest extends ComponentBaseTest { String resourceYaml = null; byte[] buffer = new byte[1024]; ZipEntry nextEntry = zip.getNextEntry(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int len; while ((len = zip.read(buffer)) > 0) { @@ -203,7 +203,7 @@ public class CsarUtilsTest extends ComponentBaseTest { String resourceYaml = null; byte[] buffer = new byte[1024]; ZipEntry nextEntry = zip.getNextEntry(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int len; while ((len = zip.read(buffer)) > 0) { @@ -311,7 +311,7 @@ public class CsarUtilsTest extends ComponentBaseTest { String resourceYaml = null; byte[] buffer = new byte[1024]; ZipEntry nextEntry = zip.getNextEntry(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int len; while ((len = zip.read(buffer)) > 0) { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java index 071624676f..eabf057715 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/CreateServiceMetadataApiTest.java @@ -631,7 +631,7 @@ public class CreateServiceMetadataApiTest extends ComponentBaseTest { // fill new service details ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); - StringBuffer tagBuffer = new StringBuffer(); + StringBuilder tagBuffer = new StringBuilder(); for (int i = 0; i < 1025; i++) { tagBuffer.append("a"); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java index 8e5079db92..43c93e47a6 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java @@ -774,7 +774,7 @@ public final class AtomicOperationUtils { // Get the CSARs path String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ; if (filePath != null && filePath.length > 0) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); for(String currStr: filePath){ result.append(currStr); } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java index 56859ff56a..b8ec35f0ff 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java @@ -179,7 +179,7 @@ public class BaseRestUtils extends BaseValidationUtils { int statusCode = response.getStatusLine().getStatusCode(); postResponse.setErrorCode(statusCode); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); try { BufferedReader in = new BufferedReader(new InputStreamReader(responseEntity.getContent())); String inputLine; diff --git a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java index 9ce20939f5..d03b93c727 100644 --- a/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java +++ b/utils/webseal-simulator/src/main/java/org/openecomp/sdc/webseal/simulator/RequestsClient.java @@ -117,7 +117,7 @@ public class RequestsClient extends HttpServlet { // logger.debug("Send POST http request, url: {}", url); // logger.debug("Response Code: {}", responseCode); - StringBuffer response = new StringBuffer(); + StringBuilder response = new StringBuilder(); try { BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; |