aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2017-10-23 15:08:55 +0300
committervempo <vitaliy.emporopulo@amdocs.com>2017-10-23 15:13:08 +0300
commit37d5b2c858f9f17bef12c170895e9ac03d50cf05 (patch)
tree2814ba52ce8f1e50e21e275e197477af209d83e7 /openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main
parentb75aaccf629eecac3a68d3d30edec6312fd5ec38 (diff)
Finished fixing critical static analysis issues
Release all resources such as InputStream in the onboarding code, along with automatic code cleanup and simpification. Change-Id: I0ff0bfe352ff63768d025fbd9dd85b53636e2d49 Issue-ID: SDC-291 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
index 53ebf0baab..875b51548e 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
@@ -557,15 +557,13 @@ public class ActionsImpl implements Actions {
ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_FILE);
}
- InputStream artifactInputStream = null;
- try {
- artifactInputStream = artifactToUpload.getDataHandler().getInputStream();
+ try (InputStream artifactInputStream = artifactToUpload.getDataHandler().getInputStream()) {
+ payload = FileUtils.toByteArray(artifactInputStream);
} catch (IOException exception) {
LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception);
throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR);
}
- payload = FileUtils.toByteArray(artifactInputStream);
//Validate Artifact size
if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) {
throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, ACTION_ARTIFACT_TOO_BIG_ERROR);
@@ -761,15 +759,14 @@ public class ActionsImpl implements Actions {
}
if (artifactToUpdate != null) {
- InputStream artifactInputStream = null;
- try {
- artifactInputStream = artifactToUpdate.getDataHandler().getInputStream();
+
+ try (InputStream artifactInputStream = artifactToUpdate.getDataHandler().getInputStream()) {
+ payload = FileUtils.toByteArray(artifactInputStream);
} catch (IOException exception) {
LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception);
throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR);
}
- payload = FileUtils.toByteArray(artifactInputStream);
//Validate Artifact size
if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) {
throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE,