Report, not discard, caught exception in ctor 57/106557/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Thu, 23 Apr 2020 19:57:53 +0000 (15:57 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Thu, 23 Apr 2020 20:04:37 +0000 (16:04 -0400)
The PortalRestCentralServiceImpl constructor instantiates a class by
name then calls methods on the new object.  The ctor uses try/catch
but if an exception occurs, the ctor discards that exception and
throws ClassCastException with a vague message.  Change to throw
ServletException and include the cause exception.

Change-Id: I4f9f0c03026cedff5e65fb904f24eb3f6b658fac
Issue-ID: PORTAL-865
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java

index 54ce2f4..21c3f21 100644 (file)
@@ -85,7 +85,7 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
                        password = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_PASS);
                        appName = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_APP);
                } catch (Exception e) {
-                       throw new ClassCastException("Failed to find or instantiate class ");
+                       throw new ServletException("Failed to instantiate class " + centralClassName, e);
                }
        }
 
@@ -211,4 +211,4 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService {
                return credentialsMap;
        }
 
-}
\ No newline at end of file
+}