Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance logging in ConsulFailoverInterceptor #309

Merged

Conversation

sleberknight
Copy link
Member

  • If debug level is enabled, log the exception (and stack trace) at debug level. Otherwise, log the exception at warning level including the exception type, but not the stack trace.
  • Internal refactoring to remove the duplicate calls to get() the value from the Optional. When inside the loop, we know that the Optional contains a value, so it's annoying to see repetitive calls to nextRequest.get().

Closes #305

* Add maximum failover attempts in ConsulFailoverInterceptor to
  avoid potential infinite loop.
* Set the default maximum to 10 attempts.
* Add new method withMaxFailoverAttempts to allow changing the maximum.
* Add MaxFailoverAttemptsExceededException as a RuntimeException that
  is thrown if the maximum failover attempts are exceeded.

Closes #304
* If debug level is enabled, log the exception (and stack trace) at
  debug level. Otherwise, log the exception at warning level including
  the exception type, but not the stack trace.
* Internal refactoring to remove the duplicate calls to get() the
  value from the Optional<Request>. When inside the loop, we know
  that the Optional contains a value, so it's annoying to see
  repetitive calls to nextRequest.get().

Closes #305
@sleberknight sleberknight self-assigned this Dec 17, 2023
@sleberknight sleberknight marked this pull request as draft December 17, 2023 15:46
@sleberknight
Copy link
Member Author

@terezivy Note that the base branch for this is 304-add-max-failover-attempts-to-avoid-infinite-loop, not master. So, once approved I will need to do some git shenanigans to change it.

@sleberknight
Copy link
Member Author

@terezivy Actually, apparently you can just edit the base branch, so it will be easy once #307 is merged.

Base automatically changed from 304-add-max-failover-attempts-to-avoid-infinite-loop to master December 17, 2023 16:23
* Log warning if Consul failover interceptor is set multiple times

* Log a warning in Consul if both withMultipleHostAndPort and
  withFailoverInterceptor are called when building a Consul
  instance.
* This is important because calling them both results in a
  "last one wins" scenario, since the last method called
  sets the failover interceptor.

Closes #306

* Update javadocs regarding overriding failover interceptors
* Replace Jetbrains NotNull and VisibleForTesting annotations
  with the ones from Checker and Guava, respectively.
* The reason is that the Jetbrains annotations come in transitively
  whereas Checker and Guava are both direct dependencies. While
  not a huge deal, we also have (more or less) standardized on
  using the Checker annotations for nullability, and on Guava's
  VisibleForTesting annotation.
The reason is that, since the while loop's Optional#isPresent test
was true, the Optional#get call must succeed inside the loop body.
Otherwise, something else (i.e., a coding error) is wrong.
@sleberknight sleberknight marked this pull request as ready for review December 17, 2023 17:00
Copy link

@sleberknight sleberknight merged commit 262b41d into master Dec 17, 2023
5 checks passed
@sleberknight sleberknight deleted the 305-enhance-logging-in-consul-failover-interceptor branch December 17, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change logging in ConsulFailoverInterceptor to WARN level
2 participants