Skip to content

Commit

Permalink
Fixup cache encoding (#64)
Browse files Browse the repository at this point in the history
* Fixup cache encoding
  • Loading branch information
tmiddlet2666 authored Apr 19, 2023
1 parent 2d038d1 commit 7e028db
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
Expand Down Expand Up @@ -311,7 +314,7 @@ public Set<ObjectName> getCacheMembers(String sServiceName, String sCacheName, S
{
URLBuilder urlBuilder = getBasePath().addPathSegment(SERVICES)
.addPathSegment(encodeServiceName(sServiceName)).addPathSegment(CACHES)
.addPathSegment(sCacheName).addPathSegment(MEMBERS);
.addPathSegment(encodeCacheName(sCacheName)).addPathSegment(MEMBERS);
if (sDomainPartition != null)
{
urlBuilder.addQueryParameter("domainPartition", sDomainPartition);
Expand Down Expand Up @@ -986,7 +989,7 @@ public JsonNode getDataForStorageManagerMembers(String sServiceName, String sDom
throws Exception
{
URLBuilder urlBuilder = getBasePath().addPathSegment(SERVICES)
.addPathSegment(encodeServiceName(sServiceName)).addPathSegment(CACHES).addPathSegment(sCacheName)
.addPathSegment(encodeServiceName(sServiceName)).addPathSegment(CACHES).addPathSegment(encodeCacheName(sCacheName))
.addPathSegment(MEMBERS).addQueryParameter(FIELDS,
"nodeId,locksGranted,locksPending,listenerRegistrations,maxQueryDurationMillis,maxQueryDescription," +
"nonOptimizedQueryAverageMillis,optimizedQueryAverageMillis,indexTotalUnits,indexingTotalMillis," +
Expand Down Expand Up @@ -1016,7 +1019,7 @@ public JsonNode getDataForCacheMembers(String sServiceName, String sCacheName, S
throws Exception
{
URLBuilder urlBuilder = getBasePath().addPathSegment(SERVICES)
.addPathSegment(encodeServiceName(sServiceName)).addPathSegment(CACHES).addPathSegment(sCacheName)
.addPathSegment(encodeServiceName(sServiceName)).addPathSegment(CACHES).addPathSegment(encodeCacheName(sCacheName))
.addPathSegment(MEMBERS);
if (sDomainPartition != null)
{
Expand Down Expand Up @@ -1817,6 +1820,24 @@ private String encodeServiceName(String sServiceName)
return sServiceName.replaceAll("\"", "");
}

/**
* Encode a cache name.
*
* @param sCacheName service name to encode
* @return encoded cache name
*/
private String encodeCacheName(String sCacheName)
{
try
{
return URLEncoder.encode(sCacheName, "UTF8");
}
catch (UnsupportedEncodingException e)
{
return sCacheName;
}
}

/**
* Internal class to build a URL.
*/
Expand Down

0 comments on commit 7e028db

Please sign in to comment.