Skip to content

Commit 5d0a0bc

Browse files
author
Valentin Popov
committed
performance improvement
1 parent 5c55675 commit 5d0a0bc

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.net.URL;
77
import java.util.Arrays;
8+
import java.util.Collections;
89
import java.util.List;
910
import java.util.Objects;
1011
import java.util.concurrent.CompletableFuture;
@@ -27,7 +28,7 @@ public class TokenCredentialAuthProvider extends BaseAuthenticationProvider {
2728
* @param tokenCredential Credential object inheriting the TokenCredential interface used to instantiate the Auth Provider
2829
*/
2930
public TokenCredentialAuthProvider(@Nonnull final TokenCredential tokenCredential) {
30-
this(Arrays.asList(DEFAULT_GRAPH_SCOPE), tokenCredential);
31+
this(Collections.singletonList(DEFAULT_GRAPH_SCOPE), tokenCredential);
3132
}
3233

3334
/**

src/main/java/com/microsoft/graph/core/Multipart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static String createContentHeaderValue(@Nonnull final String contentValue
125125

126126
if(contentDispParameter != null) {
127127
for(Map.Entry<String,String> entry : contentDispParameter.entrySet())
128-
builder.append(";" + entry.getKey() + "=\"" + entry.getValue() + "\"");
128+
builder.append(";").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"");
129129
}
130130
return builder.toString();
131131
}
@@ -140,7 +140,7 @@ private String createPartHeader(Map<String, String> headers) {
140140

141141
if(headers != null) {
142142
for(Map.Entry<String,String> entry : headers.entrySet())
143-
builder.append(entry.getKey() +": "+entry.getValue() + RETURN);
143+
builder.append(entry.getKey()).append(": ").append(entry.getValue()).append(RETURN);
144144
builder.append(RETURN);
145145
} else
146146
builder.append(defaultPartContent);

src/main/java/com/microsoft/graph/http/BaseRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private String addFunctionParameters() {
228228
requestUrl.append("=");
229229
if (option.getValue() != null) {
230230
if (option.getValue() instanceof String) {
231-
requestUrl.append("'" + option.getValue() + "'");
231+
requestUrl.append("'").append(option.getValue()).append("'");
232232
} else {
233233
requestUrl.append(option.getValue());
234234
}

src/main/java/com/microsoft/graph/httpcore/HttpClients.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
package com.microsoft.graph.httpcore;
22

33
import com.microsoft.graph.authentication.IAuthenticationProvider;
4-
5-
import java.util.Arrays;
6-
import java.util.Objects;
7-
8-
import javax.annotation.Nullable;
9-
import javax.annotation.Nonnull;
10-
114
import okhttp3.Interceptor;
125
import okhttp3.OkHttpClient;
13-
import okhttp3.Protocol;
146
import okhttp3.OkHttpClient.Builder;
7+
import okhttp3.Protocol;
8+
9+
import javax.annotation.Nonnull;
10+
import javax.annotation.Nullable;
11+
import java.util.Collections;
12+
import java.util.Objects;
1513

1614
/**
1715
* Builder to get a custom HttpClient to be used for requests against Microsoft Graph
@@ -33,7 +31,7 @@ public static Builder custom() {
3331
.addInterceptor(new TelemetryHandler())
3432
.followRedirects(false)
3533
.followSslRedirects(false)
36-
.protocols(Arrays.asList(Protocol.HTTP_1_1)); //https://stackoverflow.com/questions/62031298/sockettimeout-on-java-11-but-not-on-java-8
34+
.protocols(Collections.singletonList(Protocol.HTTP_1_1)); //https://stackoverflow.com/questions/62031298/sockettimeout-on-java-11-but-not-on-java-8
3735
}
3836

3937
/**

0 commit comments

Comments
 (0)