diff --git a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java index 8f733274c..7a43b423b 100644 --- a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java +++ b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java @@ -133,30 +133,10 @@ public XrplClient(final HttpUrl rippledUrl) { /** * Public constructor that allows for configuration of connect and read timeouts. - * - * @param rippledUrl The {@link HttpUrl} of the node to connect to. - * @param connectTimeout A {@code long} indicating the client's connect timeout. - * @param connectTimeoutUnit The {@link TimeUnit} that {@code connectTimeout} is denominated in. - * @param readTimeout A {@code long} indicating the client's read timeout. - * @param readTimeoutUnit The {@link TimeUnit} that {@code readTimeout} is denominated in. - */ - public XrplClient( - HttpUrl rippledUrl, - long connectTimeout, - TimeUnit connectTimeoutUnit, - long readTimeout, - TimeUnit readTimeoutUnit - ) { - this( - JsonRpcClient.construct( - rippledUrl, - new Options(connectTimeout, connectTimeoutUnit, readTimeout, readTimeoutUnit, true) - ) - ); - } - - /** - * Public constructor that allows for configuration of connect and read timeouts. + *

+ * Note that any {@link Duration} passed in that is less than one millisecond will result in the actual timeout being + * zero milliseconds. It is therefore advised to never set {@code connectTimeout} or {@code readTimeout} to a + * {@link Duration} less than one millisecond. * * @param rippledUrl The {@link HttpUrl} of the node to connect to. * @param connectTimeout A {@link Duration} indicating the client's connect timeout. @@ -170,7 +150,8 @@ public XrplClient( this( JsonRpcClient.construct( rippledUrl, - new Options(connectTimeout.toNanos(), TimeUnit.NANOSECONDS, readTimeout.toNanos(), TimeUnit.NANOSECONDS, true) + new Options(connectTimeout.toMillis(), TimeUnit.MILLISECONDS, readTimeout.toMillis(), TimeUnit.MILLISECONDS, + true) ) ); } diff --git a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java index 3dc744e47..2aa720346 100644 --- a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java +++ b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java @@ -601,20 +601,6 @@ public void getXrplClientTest() { assertThat(new XrplClient(rippledUrl) instanceof JsonRpcClient).isFalse(); } - @Test - void createXrplClientWithTimeouts() { - HttpUrl rippledUrl = HttpUrl.parse("https://s.altnet.rippletest.net:51234"); - XrplClient client = new XrplClient( - rippledUrl, - 1, - TimeUnit.SECONDS, - 2, - TimeUnit.MINUTES - ); - - assertThat(client).isInstanceOf(XrplClient.class); - } - @Test void createXrplClientWithDurationTimeouts() { HttpUrl rippledUrl = HttpUrl.parse("https://s.altnet.rippletest.net:51234");