Skip to content

Commit

Permalink
Use unmodifiableSortedMap instead of unModifiableMap when wrapping tr…
Browse files Browse the repository at this point in the history
…eemaps to ensure that bulk copy operations are faster when copied onto another TreeMap

RB=1919280
R=rtecco,kbalasub,mnchen
A=rtecco,lcarmody
  • Loading branch information
li-kramgopa committed Dec 20, 2019
1 parent 2fb4679 commit aa4d897
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
28.1.4
------

28.1.3
------
(RB=1920382)
Expand All @@ -9,6 +12,9 @@ Use PDL in examples and restli-example-api
(RB=1882175)
Dark cluster schema and serializer changes

(RB=1919280)
Use unmodifiableSortedMap instead of unModifiableMap when wrapping treemaps to ensure that bulk copy operations are faster when copied onto another TreeMap.

(RB=1913253)
Fix convertToPdl tool validation issue when there is an extra whitespace in the beginning of a line in doc.

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=28.1.2
version=28.1.3
sonatypeUsername=please_set_in_home_dir_if_uploading_to_maven_central
sonatypePassword=please_set_in_home_dir_if_uploading_to_maven_central
org.gradle.configureondemand=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ protected BaseMessage(Map<String, String> headers, List<String> cookies)
{
ArgumentUtil.notNull(headers, "headers");
ArgumentUtil.notNull(cookies, "cookies");
Map<String, String> tmpHeaders = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
TreeMap<String, String> tmpHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
tmpHeaders.putAll(headers);
_headers = Collections.unmodifiableMap(tmpHeaders);
_cookies = Collections.unmodifiableList(new ArrayList<String>(cookies));
_headers = Collections.unmodifiableSortedMap(tmpHeaders);
_cookies = Collections.unmodifiableList(new ArrayList<>(cookies));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class BaseMessageBuilder<B extends BaseMessageBuilder<B>>

private static final String CANONICAL_REPLACEMENT = " ";

private Map<String, String> _headers;
private TreeMap<String, String> _headers;

private List<String> _cookies;

Expand Down Expand Up @@ -139,7 +139,7 @@ public B clearCookies()
@Override
public Map<String, String> getHeaders()
{
return Collections.unmodifiableMap(_headers);
return Collections.unmodifiableSortedMap(_headers);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Map<String, String> removeWireAttributes(Map<String, String> map)
{
final Map.Entry<String, String> entry = it.next();
final String key = entry.getKey();
if (key.toUpperCase().startsWith(WIRE_ATTR_PREFIX))
if (key.regionMatches(true, 0, WIRE_ATTR_PREFIX, 0, WIRE_ATTR_PREFIX.length()))
{
final String value = entry.getValue();
final String newKey = key.substring(WIRE_ATTR_PREFIX.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,9 @@ protected List<HttpCookie> buildReadOnlyCookies()

static protected Map<String, String> getReadOnlyHeaders(Map<String, String> headers)
{
Map<String, String> copyHeaders = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
TreeMap<String, String> copyHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
copyHeaders.putAll(headers);
return Collections.unmodifiableMap(copyHeaders);
return Collections.unmodifiableSortedMap(copyHeaders);
}

static protected List<HttpCookie> getReadOnlyCookies(List<HttpCookie> cookies)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public MultiplexedResponse(int status, Map<String, String> headers)
// see com.linkedin.restli.internal.client.ResponseImpl.ResponseImpl()
TreeMap<String, String> headersTreeMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
headersTreeMap.putAll(headers);
_headers = Collections.unmodifiableMap(headersTreeMap);
_headers = Collections.unmodifiableSortedMap(headersTreeMap);
}

public int getStatus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
public class ResponseImpl<T> implements Response<T>
{
private int _status = 102; // SC_PROCESSING
private final Map<String, String> _headers;
private final TreeMap<String, String> _headers;
private final List<HttpCookie> _cookies;
private T _entity;
private RestLiResponseException _error;
Expand Down Expand Up @@ -126,7 +126,7 @@ public void setEntity(T entity)
@Override
public Map<String, String> getHeaders()
{
return Collections.unmodifiableMap(_headers);
return Collections.unmodifiableSortedMap(_headers);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public class ResourceContextImpl implements ServerResourceContext
private final MutablePathKeys _pathKeys;
private final Request _request;
private final DataMap _parameters;
private final Map<String, String> _requestHeaders;
private final Map<String, String> _responseHeaders;
private final TreeMap<String, String> _requestHeaders;
private final TreeMap<String, String> _responseHeaders;
private final List<HttpCookie> _requestCookies;
private final List<HttpCookie> _responseCookies;
private final Map<Object, RestLiServiceException> _batchKeyErrors;
Expand Down Expand Up @@ -472,7 +472,7 @@ public RequestContext getRawRequestContext()
@Override
public Map<String, String> getResponseHeaders()
{
return Collections.unmodifiableMap(_responseHeaders);
return Collections.unmodifiableSortedMap(_responseHeaders);
}

@Override
Expand Down

0 comments on commit aa4d897

Please sign in to comment.