diff --git a/src/main/java/org/jboss/aerogear/keycloak/metrics/ResourceExtractor.java b/src/main/java/org/jboss/aerogear/keycloak/metrics/ResourceExtractor.java index 4f52f5b..9fafca3 100644 --- a/src/main/java/org/jboss/aerogear/keycloak/metrics/ResourceExtractor.java +++ b/src/main/java/org/jboss/aerogear/keycloak/metrics/ResourceExtractor.java @@ -65,21 +65,23 @@ static String getResource(UriInfo uriInfo) { static String getURI(UriInfo uriInfo) { if (URI_METRICS_ENABLED) { List matchedURIs = uriInfo.getMatchedURIs(); - StringBuilder sb = new StringBuilder(); + if (!matchedURIs.isEmpty()) { + StringBuilder sb = new StringBuilder(); - if (URI_METRICS_FILTER != null && URI_METRICS_FILTER.length() != 0) { - String[] filter = URI_METRICS_FILTER.split(","); + if (URI_METRICS_FILTER != null && URI_METRICS_FILTER.length() != 0) { + String[] filter = URI_METRICS_FILTER.split(","); - for (int i = 0; i < filter.length; i++) { - if (matchedURIs.get(0).contains(filter[i])) { + for (int i = 0; i < filter.length; i++) { + if (matchedURIs.get(0).contains(filter[i])) { - sb = getURIDetailed(sb, matchedURIs); + sb = getURIDetailed(sb, matchedURIs); + } } + } else { + sb = getURIDetailed(sb, matchedURIs); } - } else { - sb = getURIDetailed(sb, matchedURIs); + return sb.toString(); } - return sb.toString(); } return ""; }