diff options
author | siddharth0905 <siddharth.singh4@amdocs.com> | 2018-08-13 22:09:54 +0530 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-08-16 19:27:58 +0000 |
commit | 054dea4806c2d9a37b4f3cf72510dfbe6d47c6f9 (patch) | |
tree | 6006e56902efa0dd28ab96f53037f276f68205b7 | |
parent | 3a9c18a098c3f5c519fb0dbed36384af6ccaf151 (diff) |
Fortify SDC issue
Fortify SDC issue
Change-Id: I7acf3420080ed4c7045aeda1cb1ff0d31d9b5228
Issue-ID: SDC-1644
Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
4 files changed, 27 insertions, 25 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/Config.java b/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/Config.java index b4cd68df5d..406f45af92 100644 --- a/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/Config.java +++ b/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/Config.java @@ -12,10 +12,10 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) public @interface Config { - /** - * Key string. - * - * @return the string - */ - String key() default ""; + /** + * Key string. + * + * @return the string + */ + String key(); } diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java index cff9da0d5c..9d25a09758 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java @@ -16,21 +16,20 @@ package org.openecomp.core.factory.impl; - -import org.apache.commons.lang3.StringUtils; -import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.errors.ErrorCategory; -import org.openecomp.sdc.common.errors.ErrorCode; +import static org.openecomp.core.utilities.CommonMethods.newInstance; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static org.openecomp.core.utilities.CommonMethods.newInstance; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; public abstract class AbstractFactoryBase { - /** + /** * Temporary registry of default implementations. The map keeps class names rather then class * types to allow unloading of those classes from memory by garbage collector if factory is not * actually used. @@ -41,8 +40,9 @@ public abstract class AbstractFactoryBase { * Cached factory instances. */ private static final Map<String, AbstractFactoryBase> FACTORY_MAP = new ConcurrentHashMap<>(); + public static final String E0001 = "E0001"; - /** + /** * Registers implementor for an abstract factory. The method accepts Java classes rather then * class names to ensure type safety at compilation time. * @@ -55,13 +55,13 @@ public abstract class AbstractFactoryBase { Class<? extends F> impl) { if (factory == null) { throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withId("E0001").withMessage("Mandatory input factory.") + new ErrorCode.ErrorCodeBuilder().withId(E0001).withMessage("Mandatory input factory.") .withCategory(ErrorCategory.SYSTEM).build()); } if (impl == null) { throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withId("E0001").withMessage("Mandatory input impl.") + new ErrorCode.ErrorCodeBuilder().withId(E0001).withMessage("Mandatory input impl.") .withCategory(ErrorCategory.SYSTEM).build()); } if (FACTORY_MAP.containsKey(factory.getName())) { @@ -84,7 +84,7 @@ public abstract class AbstractFactoryBase { public static <F extends AbstractFactoryBase> void unregisterFactory(Class<F> factory) { if (factory == null) { throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withId("E0001").withMessage("Mandatory input factory.") + new ErrorCode.ErrorCodeBuilder().withId(E0001).withMessage("Mandatory input factory.") .withCategory(ErrorCategory.SYSTEM).build()); } @@ -103,7 +103,7 @@ public abstract class AbstractFactoryBase { public static <I, F extends AbstractFactoryBase> F getInstance(Class<F> factoryType) { if (factoryType == null) { throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withId("E0001") + new ErrorCode.ErrorCodeBuilder().withId(E0001) .withMessage("Mandatory input factory type.").withCategory(ErrorCategory.SYSTEM) .build()); @@ -113,7 +113,7 @@ public abstract class AbstractFactoryBase { // Check for the first time access if (factory == null) { // Synchronize factory instantiation - synchronized (factoryType) { + synchronized (FACTORY_MAP) { // Re-check the factory instance factory = (F) FACTORY_MAP.get(factoryType.getName()); if (factory == null) { @@ -122,7 +122,7 @@ public abstract class AbstractFactoryBase { if (StringUtils.isEmpty(implName)) { throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withId("E0001") + new ErrorCode.ErrorCodeBuilder().withId(E0001) .withMessage("Mandatory input factory implementation.") .withCategory(ErrorCategory.SYSTEM).build()); } @@ -153,7 +153,7 @@ public abstract class AbstractFactoryBase { boolean isFactoryRegistered = false; if (factoryType == null) { throw new CoreException( - new ErrorCode.ErrorCodeBuilder().withId("E0001") + new ErrorCode.ErrorCodeBuilder().withId(E0001) .withMessage("Mandatory input factory type.").withCategory(ErrorCategory.SYSTEM) .build()); } diff --git a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/configuration/ImplementationConfiguration.java b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/configuration/ImplementationConfiguration.java index d95b648bcd..a9a01fe6dd 100644 --- a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/configuration/ImplementationConfiguration.java +++ b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/configuration/ImplementationConfiguration.java @@ -28,7 +28,7 @@ import java.util.Map; * @author shiria * @since November 30, 2016. */ -@Config +@Config(key = "") public class ImplementationConfiguration { @Config(key = "enable") Boolean enable = true; diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java index 249ba5e145..d36b41f7c2 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java @@ -132,10 +132,12 @@ public class ImportSingleTable { private String createQuery(TableData tableData) { ColumnDefinition def = tableData.definitions.iterator().next(); - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(1024); sb.append(INSERT_INTO).append(def.getKeyspace()).append(".").append(def.getTable()); - sb.append(tableData.definitions.stream().map(ColumnDefinition::getName).collect(Collectors.joining(" , ", " ( ", " ) "))); - sb.append(VALUES).append(tableData.definitions.stream().map(definition -> "?").collect(Collectors.joining(" , ", " ( ", " ) "))).append(";"); + sb.append(tableData.definitions.stream().map(ColumnDefinition::getName) + .collect(Collectors.joining(" , ", " ( ", " ) "))); + sb.append(VALUES).append(tableData.definitions.stream().map(definition -> "?") + .collect(Collectors.joining(" , ", " ( ", " ) "))).append(";"); return sb.toString(); } |