Refactor service port extraction in metric handler.
@@ -369,8 +369,10 @@ public class MetricHandler extends AbstractExtendedSynapseHandler {
getProperty(NhttpConstants.SERVICE_PREFIX)) {
String servicePort = ((Axis2MessageContext) synCtx).getAxis2MessageContext().
getProperty(NhttpConstants.SERVICE_PREFIX).toString();
- servicePort = servicePort.substring((servicePort.lastIndexOf(':') + 1),
- servicePort.lastIndexOf(DELIMITER));
+ servicePort = servicePort.substring(servicePort.lastIndexOf(':') + 1);
+ if (servicePort.contains(DELIMITER)) {
+ servicePort = servicePort.substring(0, servicePort.indexOf(DELIMITER));
+ }
invokePort = Integer.parseInt(servicePort);
}
return invokePort;
