Fix errors static initialization block 62/1162/1
authorSerban Jora <sj2381@att.com>
Fri, 2 Mar 2018 04:31:12 +0000 (23:31 -0500)
committerSerban Jora <sj2381@att.com>
Fri, 2 Mar 2018 04:31:40 +0000 (23:31 -0500)
Change-Id: I57b72097f4cf8912b4ec71bd1f058bebd4fbefd8
Signed-off-by: Serban Jora <sj2381@att.com>
Issue-ID: MODELING-276

gateway/src/main/java/org/acumos/federation/gateway/adapter/PeerGateway.java
gateway/src/main/java/org/acumos/federation/gateway/util/Errors.java

index cad87e5..4c3e473 100644 (file)
@@ -154,30 +154,17 @@ public class PeerGateway {
                                MLPSolution localSolution = null;
                                log.info(EELFLoggerDelegate.debugLogger, "Processing peer solution {}", peerSolution);
                                try {
-                                       localSolution = cdsClient.getSolution(peerSolution.getSolutionId());
-                               } 
-                               catch (HttpStatusCodeException scx) {
-                               try {
-                                       if (!Errors.isCDSNotFound(scx)) {
-                                               log.error(EELFLoggerDelegate.errorLogger, "Failed to check if solution with id "
+                                       try {
+                                               localSolution = cdsClient.getSolution(peerSolution.getSolutionId());
+                                       } 
+                                       catch (HttpStatusCodeException scx) {
+                                               if (!Errors.isCDSNotFound(scx)) {
+                                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to check if solution with id "
                                                                + peerSolution.getSolutionId() + " exists locally, skipping for now. Response says " + scx.getResponseBodyAsString(), scx);
-                                               continue;
+                                                       continue;
+                                               }
                                        }
-                               }
-                               catch (Exception tx) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Unexpected error while checking not found on "
-                                                               + peerSolution.getSolutionId(), tx);
-                                       continue;
-                               }
 
-                               }
-                               catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Unexpected error while checking if solution with id "
-                                                               + peerSolution.getSolutionId() + " exists locally, skipping for now.", x);
-                                       continue;
-                               }
-
-                               try {
                                        if (localSolution == null) {
                                                log.info(EELFLoggerDelegate.debugLogger, "Solution Id : " + peerSolution.getSolutionId()
                                                                + " does not exists locally, adding it to local catalog ");
@@ -191,9 +178,9 @@ public class PeerGateway {
 
                                        mapSolution(localSolution, cdsClient);
                                }
-                               catch (Exception x) {
+                               catch (Throwable t) {
                                        log.error(EELFLoggerDelegate.errorLogger,
-                                                       "Mapping of acumos solution failed for: " + peerSolution, x);
+                                                       "Mapping of acumos solution failed for " + peerSolution, t);
                                }
                        }
                }
index 92efa4b..40d410a 100644 (file)
@@ -21,6 +21,7 @@
 package org.acumos.federation.gateway.util;
 
 import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 import java.util.regex.PatternSyntaxException;
 
 import org.springframework.http.HttpStatus;
@@ -33,7 +34,7 @@ public class Errors {
        }
 
        private static Pattern cdsNotFoundPattern = null;
-       {
+       static {
                try {
                        cdsNotFoundPattern = Pattern.compile("No (.*) with ID (.*)");
                }