File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
foreign/java/java-sdk/src
main/java/org/apache/iggy/client/async/tcp
test/java/org/apache/iggy/client/async/tcp Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -259,9 +259,16 @@ private void validateConnectionPoolSize() {
259259 }
260260
261261 private void validateConnectionTimeout () {
262- if (connectionTimeout != null && (connectionTimeout .equals (Duration .ZERO ) || connectionTimeout .isNegative ())) {
262+ if (connectionTimeout == null ) {
263+ return ;
264+ }
265+ if (connectionTimeout .equals (Duration .ZERO ) || connectionTimeout .isNegative ()) {
263266 throw new IggyInvalidArgumentException ("ConnectionTimeout Cannot be 0 or Negative" );
264267 }
268+ if (connectionTimeout .toMillis () > ((long ) Integer .MAX_VALUE )) {
269+ throw new IggyInvalidArgumentException (
270+ String .format ("ConnectionTimeout Cannot be greater than %d" , Integer .MAX_VALUE ));
271+ }
265272 }
266273
267274 private void validateAcquireTimeout () {
Original file line number Diff line number Diff line change @@ -183,6 +183,16 @@ void shouldThrowExceptionForNegativeConnectionTimeout() {
183183 assertThatThrownBy (builder ::build ).isInstanceOf (IggyInvalidArgumentException .class );
184184 }
185185
186+ @ Test
187+ void shouldThrowExceptionForConnectionTimeoutInMillisecondsGreaterThanMaximumInteger () {
188+ // Given: Builder with connection timeout in milliseconds greater than maximum integer
189+ AsyncIggyTcpClientBuilder builder =
190+ AsyncIggyTcpClient .builder ().connectionTimeout (Duration .ofMillis (((long ) Integer .MAX_VALUE ) + 1 ));
191+
192+ // When/Then: Building should throw IggyInvalidArgumentException
193+ assertThatThrownBy (builder ::build ).isInstanceOf (IggyInvalidArgumentException .class );
194+ }
195+
186196 @ Test
187197 void shouldThrowExceptionForZeroAcquireTimeout () {
188198 // Given: Builder with 0 acquire timeout
You can’t perform that action at this time.
0 commit comments