From ab105cdcfaf19407778301d2193dada1ac647399 Mon Sep 17 00:00:00 2001 From: Misagh Moayyed Date: Wed, 19 Aug 2015 08:51:28 -0700 Subject: [PATCH] initialize service parameter names once, statically --- .../jasig/cas/client/util/CommonUtils.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java b/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java index d8881e3..639b3b4 100644 --- a/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java +++ b/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java @@ -59,10 +59,21 @@ public final class CommonUtils { private static final HttpURLConnectionFactory DEFAULT_URL_CONNECTION_FACTORY = new HttpsURLConnectionFactory(); + private static final String SERVICE_PARAMETER_NAMES; + private CommonUtils() { // nothing to do } + static { + final Set serviceParameterSet = new HashSet(4); + for (final Protocol protocol : Protocol.values()) { + serviceParameterSet.add(protocol.getServiceParameterName()); + } + SERVICE_PARAMETER_NAMES = serviceParameterSet.toString() + .replaceAll("\\[|\\]", "") + .replaceAll("\\s", ""); + } /** * Check whether the object is null or not. If it is, throw an exception and * display the message. @@ -281,15 +292,7 @@ public final class CommonUtils { public static String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final String service, final String serverNames, final String artifactParameterName, final boolean encode) { - final Set serviceParameterSet = new HashSet(4); - for (final Protocol protocol : Protocol.values()) { - serviceParameterSet.add(protocol.getServiceParameterName()); - } - final String serviceParameterNames = serviceParameterSet.toString() - .replaceAll("\\[|\\]", "") - .replaceAll("\\s", ""); - - return constructServiceUrl(request, response, service, serverNames, serviceParameterNames + return constructServiceUrl(request, response, service, serverNames, SERVICE_PARAMETER_NAMES , artifactParameterName, encode); }