-
Notifications
You must be signed in to change notification settings - Fork 106
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
Support for setting uncaught exception handler #780
Support for setting uncaught exception handler #780
Conversation
...src/test/groovy/io/micronaut/configuration/kafka/streams/uncaught/OnErrorNoConfigClient.java
Show resolved
Hide resolved
...c/test/groovy/io/micronaut/configuration/kafka/streams/uncaught/OnErrorNoConfigListener.java
Show resolved
Hide resolved
.../src/test/groovy/io/micronaut/configuration/kafka/streams/uncaught/OnErrorReplaceClient.java
Show resolved
Hide resolved
...rc/test/groovy/io/micronaut/configuration/kafka/streams/uncaught/OnErrorReplaceListener.java
Show resolved
Hide resolved
.../src/test/groovy/io/micronaut/configuration/kafka/streams/uncaught/OnErrorStreamFactory.java
Show resolved
Hide resolved
...ovy/io/micronaut/configuration/kafka/streams/uncaught/MyStreamsUncaughtExceptionHandler.java
Outdated
Show resolved
Hide resolved
412e917
to
de8b0f3
Compare
de8b0f3
to
9eb8fb3
Compare
SonarQube keeps reporting low coverage, but I added specific tests to cover new code. When I run them locally, I get 100% coverage so I'm wondering if there might be something wrong in the project config. I tried several approaches to try and make SonarQube acknowledge the actual code coverage:
But sadly, no luck. My next approach would be to move the new code to its own Any ideas what I can do to convince SonarQube that the new code is actually covered by the new tests? |
kafka-streams/src/main/java/io/micronaut/configuration/kafka/streams/KafkaStreamsFactory.java
Outdated
Show resolved
Hide resolved
...ovy/io/micronaut/configuration/kafka/streams/uncaught/MyStreamsUncaughtExceptionHandler.java
Outdated
Show resolved
Hide resolved
LOG.warn("Ignoring illegal exception handler: {}. Please use one of: {}", action, | ||
asList(StreamThreadExceptionResponse.values())); | ||
} | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do something like?
/**
* Make an uncaught exception handler for a given kafka streams configuration.
*
* @param properties The kafka streams configuration.
* @return An optional exception handler if {@code uncaught-exception-handler} was configured.
*/
private Optional<StreamsUncaughtExceptionHandler> makeUncaughtExceptionHandler(Properties properties) {
return Optional.ofNullable(properties.getProperty(UNCAUGHT_EXCEPTION_HANDLER_PROPERTY))
.filter(not(String::isBlank))
.flatMap(this::makeUncaughtExceptionHandler);
}
private Optional<StreamsUncaughtExceptionHandler> makeUncaughtExceptionHandler(String action) {
try {
final StreamThreadExceptionResponse response = StreamThreadExceptionResponse.valueOf(action.toUpperCase());
return exception -> {
if (LOG.isWarnEnabled()) {
LOG.warn("Responding with {} to unexpected exception thrown by kafka stream thread", response, exception);
}
return Optional.of(response);
};
} catch (IllegalArgumentException e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Ignoring illegal exception handler: {}. Please use one of: {}", action,
asList(StreamThreadExceptionResponse.values()));
}
return Optional.empty();
}
});
}
Kudos, SonarCloud Quality Gate passed! |
Closes #424