Fixed Blocker issues. 15/15915/2
authorseshukm <seshu.kumar.m@huawei.com>
Wed, 27 Sep 2017 10:20:30 +0000 (15:50 +0530)
committerseshukm <seshu.kumar.m@huawei.com>
Wed, 27 Sep 2017 11:51:10 +0000 (17:21 +0530)
IssueId: SO-165

Change-Id: I7c2520af9394ceb600a5a25fa9acfd095d872a1d
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java
adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallback.java
adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java
adapters/mso-workflow-message-adapter/src/main/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallback.java
asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java
common/src/main/java/org/openecomp/mso/yangDecoder/transform/impl/TransformJava2JsonFactory.java
common/src/main/java/org/openecomp/mso/yangDecoder/transform/impl/TransformJava2XMLFactory.java

index 757ea82..7473950 100644 (file)
@@ -199,7 +199,7 @@ public class SDNCRestClient implements Runnable {
                        //default
                        sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
                        String respMsg = "Error processing request to SDNC. ";
-                       String sdncErrMsg = null;
+                       String sdncErrMsg = "";
 
                        if (e instanceof java.net.SocketTimeoutException )
                        {
@@ -264,9 +264,7 @@ public class SDNCRestClient implements Runnable {
                        if (e.getMessage() != null) {
                 respMsg = respMsg + e.getMessage();
             }
-                       if (sdncErrMsg != null) {
-                respMsg = respMsg + sdncErrMsg;
-            }
+            respMsg = respMsg + sdncErrMsg;
 
                        sdncResp.setRespMsg(respMsg);
 
index 0622c48..f6708a2 100644 (file)
@@ -138,12 +138,7 @@ public class BPRestCallback {
                                        LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, msg);
                                        ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg);
                                }
-
-                               httpResponse = null;
                        }
-
-                       method.reset();
-                       method = null;
                        return true;
                } catch (Exception e) {
                        LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError,
@@ -155,6 +150,7 @@ public class BPRestCallback {
                        if (httpResponse != null) {
                                try {
                                        EntityUtils.consume(httpResponse.getEntity());
+                                       httpResponse = null;
                                } catch (Exception e) {
                                        LOGGER.debug("Exception:", e);
                                }
index a4f1046..6dc0dc3 100644 (file)
@@ -240,9 +240,6 @@ public class BpelRestClient {
                LOGGER.debug("Sending to BPEL server: "+bpelUrl);
                LOGGER.debug("Content is: "+toBpelStr);
 
-               //Client 4.3+
-               CloseableHttpClient client = HttpClients.createDefault();
-
                //POST
                HttpPost post = new HttpPost(bpelUrl);
                if (credentials != null && !credentials.isEmpty())
@@ -260,9 +257,13 @@ public class BpelRestClient {
                        .build();
                post.setConfig(requestConfig);
 
+               //Client 4.3+
+               CloseableHttpClient client = null;
+                               
         //Client 4.3+
         //Execute & GetResponse
                try {
+                       client = HttpClients.createDefault();
                        CloseableHttpResponse response = client.execute(post);
                        if (response != null) {
                                lastResponseCode = response.getStatusLine().getStatusCode();
index 253523e..0293a8d 100644 (file)
@@ -144,11 +144,8 @@ public class BPRestCallback {
                                        ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg);
                                }
 
-                               httpResponse = null;
                        }
 
-                       method.reset();
-                       method = null;
                        return true;
                } catch (Exception e) {
                        LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError,
@@ -160,6 +157,7 @@ public class BPRestCallback {
                        if (httpResponse != null) {
                                try {
                                        EntityUtils.consume(httpResponse.getEntity());
+                                       httpResponse = null;
                                } catch (Exception e) {
                                        LOGGER.debug("Exception :",e);
                                }
@@ -168,6 +166,7 @@ public class BPRestCallback {
                        if (method != null) {
                                try {
                                        method.reset();
+                                       method = null;
                                } catch (Exception e) {
                                        LOGGER.debug("Exception :",e);
                                }
index 27a21ec..11199dc 100644 (file)
@@ -573,6 +573,8 @@ public class ToscaResourceInstaller {// implements IVfResourceInstaller {
                                                "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);\r
                        }\r
 \r
+               } finally {\r
+                       catalogDB.close();\r
                }\r
                                \r
        }               \r
index 647b303..95e5948 100644 (file)
@@ -37,21 +37,28 @@ public class TransformJava2JsonFactory  extends TYangJsonXmlBase {
     @Override
     protected void setupWithDataBroker(final DataBroker dataBroker) {
         // Intentionally left No-op, subclasses may customize it
-        mappingservice = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
-                new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
-        moduleInfoBackedContext = ModuleInfoBackedContext.create();
+        
         // moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SncTunnels.class));
 
         try {
+               mappingservice = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
+                    new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
+            moduleInfoBackedContext = ModuleInfoBackedContext.create();
+            
             for (YangModuleInfo yangModuleInfo : getModuleInfos()) {
                 moduleInfoBackedContext.registerModuleInfo(yangModuleInfo);
             }
+            schemaContext = moduleInfoBackedContext.tryToCreateSchemaContext().get();
+            mappingservice.onGlobalContextUpdated(schemaContext);
+            controllerContext.setSchemas(schemaContext);
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+               if(null != mappingservice){
+                       mappingservice.close();
+               }
         }
-        schemaContext = moduleInfoBackedContext.tryToCreateSchemaContext().get();
-        mappingservice.onGlobalContextUpdated(schemaContext);
-        controllerContext.setSchemas(schemaContext);
+        
 
     }
 
index 5e5511b..ea7adc8 100644 (file)
@@ -37,20 +37,28 @@ public class TransformJava2XMLFactory extends TYangJsonXmlBase {
     @Override
     protected void setupWithDataBroker(final DataBroker dataBroker) {
         // Intentionally left No-op, subclasses may customize it
-        mappingservice = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
-                new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
-        moduleInfoBackedContext = ModuleInfoBackedContext.create();
+        
         // moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SncTunnels.class));
         try {
+               mappingservice = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
+                    new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
+            moduleInfoBackedContext = ModuleInfoBackedContext.create();
+            
             for (YangModuleInfo yangModuleInfo : getModuleInfos()) {
                 moduleInfoBackedContext.registerModuleInfo(yangModuleInfo);
             }
+            
+            schemaContext = moduleInfoBackedContext.tryToCreateSchemaContext().get();
+            mappingservice.onGlobalContextUpdated(schemaContext);
+            controllerContext.setSchemas(schemaContext);
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+               if(null != mappingservice){
+                       mappingservice.close();
+               }
         }
-        schemaContext = moduleInfoBackedContext.tryToCreateSchemaContext().get();
-        mappingservice.onGlobalContextUpdated(schemaContext);
-        controllerContext.setSchemas(schemaContext);
+        
 
     }