Skip to content

Commit

Permalink
change ttl to seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ryber committed Sep 26, 2023
1 parent 36c473f commit bd5e5cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion unirest/src/main/java/kong/unirest/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public Config setDefaultResponseEncoding(String value) {
*/
public Config connectionTTL(long duration, TimeUnit unit) {
Objects.requireNonNull(unit, "TimeUnit required");
var ttl = unit.toMillis(duration);
var ttl = unit.toSeconds(duration);
if(ttl > -1){
System.setProperty(JDK_HTTPCLIENT_KEEPALIVE_TIMEOUT, String.valueOf(ttl));
}
Expand Down
8 changes: 4 additions & 4 deletions unirest/src/test/java/kong/unirest/core/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ void willRebuildIfEmpty() {
void settingTTl() {
assertEquals(-1, config.getTTL());

assertEquals(42, config.connectionTTL(42, TimeUnit.MILLISECONDS).getTTL());
assertEquals(2520000, config.connectionTTL(42, TimeUnit.MINUTES).getTTL());
assertEquals(4, config.connectionTTL(4200, TimeUnit.MILLISECONDS).getTTL());
assertEquals(252000, config.connectionTTL(4200, TimeUnit.MINUTES).getTTL());

assertEquals(43, config.connectionTTL(Duration.ofMillis(43)).getTTL());
assertEquals(2580000, config.connectionTTL(Duration.ofMinutes(43)).getTTL());
assertEquals(4, config.connectionTTL(Duration.ofMillis(4300)).getTTL());
assertEquals(258000, config.connectionTTL(Duration.ofMinutes(4300)).getTTL());
}

@Test
Expand Down

0 comments on commit bd5e5cb

Please sign in to comment.