From b7375b2488df93ba9df57ad13ec628bbff663819 Mon Sep 17 00:00:00 2001 From: vempo Date: Thu, 7 Sep 2017 10:52:29 +0300 Subject: Fixed a few static analysis violations Fixed mostly not closing resources (InputStream, ResultSet) and catching Throwable instead of Exception in some modules. Issue-ID: SDC-291 Change-Id: I34e331cc3b45c4bb3a71c301f50e1706a7b623fd Signed-off-by: vempo --- .../sdcrests/errors/DefaultExceptionMapper.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index d399469745..2f6d298f01 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -35,29 +35,25 @@ import org.openecomp.sdc.common.errors.ValidationErrorBuilder; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.Path; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; public class DefaultExceptionMapper implements ExceptionMapper { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = "errorCodesToResponseStatusMapping.json"; @SuppressWarnings("unchecked") private static Map errorCodeToResponseStatus = - JsonUtil.json2Object(FileUtils - .getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), Map.class); + FileUtils.readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE, + stream -> JsonUtil.json2Object(stream, Map.class)); + private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class); @Override -- cgit 1.2.3-korg