Skip to content

fix(core): inconsistency connection state - #137

Merged
nickkkccc merged 1 commit into
masterfrom
connection-inconsistency-bug
Oct 23, 2026
Merged

nickkkccc merged 1 commit into
masterfrom
connection-inconsistency-bug

Conversation

@nickkkccc

@nickkkccc nickkkccc commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

In the current version of the code, if a timeout value
less than or equal to 0 is passed, an exception is thrown,
but the connection remains stuck in the CONNECTING state.
Subsequent calls to the Connection#connect(...) method on
the same object return null instead of a proper
CompletableFuture<Greeting>.

In other words, failures or errors during the execution of
Connection#connect(...) should not leave the Connection
object in an inconsistent state. Subsequent calls should be
handled correctly; the method must return a
CompletableFuture<Greeting>—either one that completes
successfully or one that contains an error, as per the
contract of the CompletionStage<T> interface.

I haven't forgotten about:

  • Tests
  • Changelog
  • Documentation
    • JavaDoc was written
  • Commit messages comply with the guideline
  • Cleanup the code for review. See checklist

Related issues:

@nickkkccc
nickkkccc force-pushed the connection-inconsistency-bug branch from 7dd092e to 9d75c4d Compare October 22, 2026 18:39
@nickkkccc nickkkccc added the bug Something isn't working label Oct 22, 2026
@nickkkccc nickkkccc self-assigned this Oct 22, 2026
Comment on lines +403 to +409
boolean errorOccurred = false;
try {
connection.connect(address, -1L).join();
} catch (IllegalStateException e) {
errorOccurred = true;
}
Assertions.assertTrue(errorOccurred, "Error must be occurred!");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему не через Assertions.assertThrows?

Comment thread CHANGELOG.md Outdated
Comment on lines +12 to +13
later call to the method returned `null` instead of a `CompletableFuture`. Now the method always
returns a future that either completes with a greeting or fails with an error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Небольшое противоречие с реальной правкой: метод либо возвращает Future, либо бросает ошибку. Это отличается от заявленного здесь - возвращает Future, которая завершается либо успешно, либо с ошибкой

@nickkkccc
nickkkccc force-pushed the connection-inconsistency-bug branch from 9d75c4d to 15591ad Compare October 23, 2026 08:36
@nickkkccc
nickkkccc force-pushed the connection-inconsistency-bug branch from 15591ad to 22e7c50 Compare October 23, 2026 08:36
  In the current version of the code, if a timeout value
  less than or equal to 0 is passed, an exception is thrown,
  but the connection remains stuck in the CONNECTING state.
  Subsequent calls to the Connection#connect(...) method on
  the same object return null instead of a proper
  CompletableFuture<Greeting>.

  In other words, failures or errors during the execution of
  Connection#connect(...) should not leave the Connection
  object in an inconsistent state. Subsequent calls should be
  handled correctly; the method must return a
  CompletableFuture<Greeting>—either one that completes
  successfully or one that contains an error, as per the
  contract of the CompletionStage<T> interface.

  Providing not positive timeout value throws an exception.
@nickkkccc
nickkkccc force-pushed the connection-inconsistency-bug branch from 22e7c50 to df9233e Compare October 23, 2026 08:37
@nickkkccc
nickkkccc merged commit c205961 into master Oct 23, 2026
11 of 16 checks passed
@nickkkccc
nickkkccc deleted the connection-inconsistency-bug branch October 23, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants