Skip to content

Commit f4121fa

Browse files
committed
Make changes as non-breaked
1 parent 4ca5a1d commit f4121fa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

NotificationHubs/src/com/windowsazure/messaging/HttpClientManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class HttpClientManager {
2222
// put differently, a maximum period inactivity between two consecutive data packets.
2323
private static int socketTimeout = -1;
2424

25-
public static CloseableHttpAsyncClient initializeHttpAsyncClient() {
25+
private static void initializeHttpAsyncClient() {
2626
synchronized (HttpClientManager.class) {
2727
if (httpAsyncClient == null) {
2828
RequestConfig config = RequestConfig.custom()
@@ -35,14 +35,14 @@ public static CloseableHttpAsyncClient initializeHttpAsyncClient() {
3535
.build();
3636
client.start();
3737
httpAsyncClient = client;
38-
} else {
39-
throw new RuntimeException("initializeHttpAsyncClient cannot be called twice or after setHttpAsyncClient.");
4038
}
4139
}
42-
return httpAsyncClient;
4340
}
4441

4542
public static CloseableHttpAsyncClient getHttpAsyncClient() {
43+
if (httpAsyncClient == null) {
44+
initializeHttpAsyncClient();
45+
}
4646
return httpAsyncClient;
4747
}
4848

@@ -51,7 +51,7 @@ public static void setHttpAsyncClient(CloseableHttpAsyncClient httpAsyncClient)
5151
if (HttpClientManager.httpAsyncClient == null) {
5252
HttpClientManager.httpAsyncClient = httpAsyncClient;
5353
} else {
54-
throw new RuntimeException("Cannot setHttpAsyncClient after having previously set, or after default already initialized.");
54+
throw new RuntimeException("Cannot setHttpAsyncClient after having previously set, or after default already initialized from earlier call to getHttpAsyncClient.");
5555
}
5656
}
5757
}
@@ -61,7 +61,7 @@ public static void setConnectionRequestTimeout(int timeout) {
6161
if (HttpClientManager.httpAsyncClient == null) {
6262
connectionRequestTimeout = timeout;
6363
} else {
64-
throw new RuntimeException("Set timeout preference only before initializeHttpAsyncClient.");
64+
throw new RuntimeException("Cannot setConnectionRequestTimeout after previously setting httpAsyncClient, or after default already initialized from earlier call to getHttpAsyncClient.");
6565
}
6666
}
6767

@@ -70,7 +70,7 @@ public static void setConnectTimeout(int timeout) {
7070
if (HttpClientManager.httpAsyncClient == null) {
7171
connectionTimeout = timeout;
7272
} else {
73-
throw new RuntimeException("Set timeout preference only before initializeHttpAsyncClient.");
73+
throw new RuntimeException("Cannot setConnectTimeout after previously setting httpAsyncClient, or after default already initialized from earlier call to getHttpAsyncClient.");
7474
}
7575
}
7676

@@ -80,7 +80,7 @@ public static void setSocketTimeout(int timeout) {
8080
if (HttpClientManager.httpAsyncClient == null) {
8181
socketTimeout = timeout;
8282
} else {
83-
throw new RuntimeException("Set timeout preference only before initializeHttpAsyncClient.");
83+
throw new RuntimeException("Cannot setSocketTimeout after previously setting httpAsyncClient, or after default already initialized from earlier call to getHttpAsyncClient.");
8484
}
8585
}
8686
}

0 commit comments

Comments
 (0)