From ec248ffb74f1c038fdd6c7a77411f628ef51366f Mon Sep 17 00:00:00 2001 From: Krishnajinka Date: Fri, 6 Jul 2018 17:28:54 +0900 Subject: null ptr check rework based on review comments Issue-ID: APPC-1047 Change-Id: Ia87707535dc5825d18a6c35fdae416064dcb8c14 Signed-off-by: Krishnajinka --- .../onap/appc/requesthandler/impl/AbstractRequestHandlerImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'appc-dispatcher/appc-request-handler') diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/impl/AbstractRequestHandlerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/impl/AbstractRequestHandlerImpl.java index aa6d203a5..cd9011f4b 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/impl/AbstractRequestHandlerImpl.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/impl/AbstractRequestHandlerImpl.java @@ -408,6 +408,13 @@ public abstract class AbstractRequestHandlerImpl implements RequestHandler { if (logger.isDebugEnabled()) logger.debug("Metric getting initialized"); MetricService metricService = getMetricservice(); + // Check for the metric service created before trying to create registry using + // the metricService object + if (metricService == null) { + // Cannot find service reference for org.onap.appc.metricservice.MetricService + throw new NullPointerException("org.onap.appc.metricservice.MetricService is null. " + + "Failed to init Metric"); + } metricRegistry = metricService.createRegistry("APPC"); DispatchingFuntionMetric dispatchingFuntionMetric = metricRegistry.metricBuilderFactory(). dispatchingFunctionCounterBuilder(). -- cgit 1.2.3-korg