Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 9f75f02

Browse files
committed
Merge pull request #15 from launchdarkly/pk/ms-timeouts
Pk/ms timeouts
2 parents 609ca83 + 6c2ca29 commit 9f75f02

File tree

9 files changed

+89
-11
lines changed

9 files changed

+89
-11
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
LaunchDarkly SDK for Java
22
=========================
33

4+
![Circle CI](https://circleci.com/gh/launchdarkly/java-client.png)
5+
46
Quick setup
57
-----------
68

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111

1212
allprojects {
1313
group = 'com.launchdarkly'
14-
version = "0.7.0"
14+
version = "0.8.0"
1515
sourceCompatibility = 1.6
1616
targetCompatibility = 1.6
1717
}

circle.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies:
2+
pre:
3+
- cp gradle.properties.example gradle.properties

gradle.properties.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
githubUser = YOUR_GITHUB_USERNAME
2+
githubPassword = YOUR_GITHUB_PASSWORD
3+
signing.keyId = 5669D902
4+
signing.password = SIGNING_PASSWORD
5+
signing.secretKeyRingFile = SECRET_RING_FILE
6+
ossrhUsername = launchdarkly
7+
ossrhPassword = OSSHR_PASSWORD

src/main/java/com/launchdarkly/client/LDClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ protected CloseableHttpClient createClient() {
8686
.build();
8787

8888
RequestConfig requestConfig = RequestConfig.custom()
89-
.setConnectTimeout(config.connectTimeout * 1000)
90-
.setSocketTimeout(config.socketTimeout * 1000)
89+
.setConnectTimeout(config.connectTimeout)
90+
.setSocketTimeout(config.socketTimeout)
9191
.build();
9292
client = CachingHttpClients.custom()
9393
.setCacheConfig(cacheConfig)

src/main/java/com/launchdarkly/client/LDConfig.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ protected LDConfig(Builder builder) {
3939
/**
4040
* A <a href="http://en.wikipedia.org/wiki/Builder_pattern">builder</a> that helps construct {@link com.launchdarkly.client.LDConfig} objects. Builder
4141
* calls can be chained, enabling the following pattern:
42-
* <p>
42+
*
4343
* <pre>
4444
* LDConfig config = new LDConfig.Builder()
4545
* .connectTimeout(3)
4646
* .socketTimeout(3)
4747
* .build()
4848
* </pre>
49-
* </p>
5049
*
5150
*/
5251
public static class Builder{
@@ -75,22 +74,56 @@ public Builder baseURI(URI baseURI) {
7574
/**
7675
* Set the connection timeout in seconds for the configuration. This is the time allowed for the underlying HTTP client to connect
7776
* to the LaunchDarkly server. The default is 2 seconds.
77+
*
78+
* <p>Both this method and {@link #connectTimeoutMillis(int) connectTimeoutMillis} affect the same property internally.</p>
79+
*
7880
* @param connectTimeout the connection timeout in seconds
7981
* @return the builder
8082
*/
8183
public Builder connectTimeout(int connectTimeout) {
82-
this.connectTimeout = connectTimeout;
84+
this.connectTimeout = connectTimeout * 1000;
8385
return this;
8486
}
8587

8688
/**
8789
* Set the socket timeout in seconds for the configuration. This is the number of seconds between successive packets that the
8890
* client will tolerate before flagging an error. The default is 10 seconds.
91+
*
92+
* <p>Both this method and {@link #socketTimeoutMillis(int) socketTimeoutMillis} affect the same property internally.</p>
93+
*
8994
* @param socketTimeout the socket timeout in seconds
9095
* @return the builder
9196
*/
9297
public Builder socketTimeout(int socketTimeout) {
93-
this.socketTimeout = socketTimeout;
98+
this.socketTimeout = socketTimeout * 1000;
99+
return this;
100+
}
101+
102+
/**
103+
* Set the connection timeout in milliseconds for the configuration. This is the time allowed for the underlying HTTP client to connect
104+
* to the LaunchDarkly server. The default is 2000 ms.
105+
*
106+
* <p>Both this method and {@link #connectTimeout(int) connectTimeout} affect the same property internally.</p>
107+
*
108+
* @param connectTimeoutMillis the connection timeout in milliseconds
109+
* @return the builder
110+
*/
111+
public Builder connectTimeoutMillis(int connectTimeoutMillis) {
112+
this.connectTimeout = connectTimeoutMillis;
113+
return this;
114+
}
115+
116+
/**
117+
* Set the socket timeout in milliseconds for the configuration. This is the number of milliseconds between successive packets that the
118+
* client will tolerate before flagging an error. The default is 10,000 milliseconds.
119+
*
120+
* <p>Both this method and {@link #socketTimeout(int) socketTimeout} affect the same property internally.</p>
121+
*
122+
* @param socketTimeoutMillis the socket timeout in milliseconds
123+
* @return the builder
124+
*/
125+
public Builder socketTimeoutMillis(int socketTimeoutMillis) {
126+
this.socketTimeout = socketTimeoutMillis;
94127
return this;
95128
}
96129

src/main/java/com/launchdarkly/client/LDCountryCode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ public Locale toLocale()
14371437
NZ("New Zealand", "NZL", 554, Assignment.OFFICIALLY_ASSIGNED),
14381438

14391439
/**
1440-
* <a href=http://en.wikipedia.org/wiki/Oman"">Oman</a>
1440+
* <a href="http://en.wikipedia.org/wiki/Oman">Oman</a>
14411441
* [<a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#OM">OM</a>, OMN, 512,
14421442
* Officially assigned]
14431443
*/
@@ -2256,7 +2256,7 @@ public Assignment getAssignment()
22562256
* {@code Locale} class.
22572257
* </p>
22582258
*
2259-
* <table border="1" style="border-collapse: collapse;" cellpadding="5">
2259+
* <table border="1" style="border-collapse: collapse;" cellpadding="5" summary="">
22602260
* <tr bgcolor="#FF8C00">
22612261
* <th>CountryCode</th>
22622262
* <th>Locale</th>

src/main/java/com/launchdarkly/client/LDUser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@ JsonElement getCustom(String key) {
9595
/**
9696
* A <a href="http://en.wikipedia.org/wiki/Builder_pattern">builder</a> that helps construct {@link com.launchdarkly.client.LDUser} objects. Builder
9797
* calls can be chained, enabling the following pattern:
98-
* <p>
98+
*
9999
* <pre>
100100
* LDUser user = new LDUser.Builder("key")
101101
* .country("US")
102102
* .ip("192.168.0.1")
103103
* .build()
104104
* </pre>
105-
* </p>
106105
*
107106
*/
108107
public static class Builder {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.launchdarkly.client;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
7+
public class LDConfigTest {
8+
@Test
9+
public void testConnectTimeoutSpecifiedInSeconds() {
10+
LDConfig config = new LDConfig.Builder().connectTimeout(3).build();
11+
12+
assertEquals(3000, config.connectTimeout);
13+
}
14+
15+
@Test
16+
public void testConnectTimeoutSpecifiedInMilliseconds() {
17+
LDConfig config = new LDConfig.Builder().connectTimeoutMillis(3000).build();
18+
19+
assertEquals(3000, config.connectTimeout);
20+
}
21+
@Test
22+
public void testSocketTimeoutSpecifiedInSeconds() {
23+
LDConfig config = new LDConfig.Builder().socketTimeout(3).build();
24+
25+
assertEquals(3000, config.socketTimeout);
26+
}
27+
28+
@Test
29+
public void testSocketTimeoutSpecifiedInMilliseconds() {
30+
LDConfig config = new LDConfig.Builder().socketTimeoutMillis(3000).build();
31+
32+
assertEquals(3000, config.socketTimeout);
33+
}
34+
}

0 commit comments

Comments
 (0)