[
https://issues.apache.org/jira/browse/CXF-9189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18045124#comment-18045124
]
Arut commented on CXF-9189:
---------------------------
Thank you, we will check it as soon as possible and give feedback! ❤️
> Exceptions Not Logged When Using SseEventSink in JAX-RS SSE Endpoint
> --------------------------------------------------------------------
>
> Key: CXF-9189
> URL: https://issues.apache.org/jira/browse/CXF-9189
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS, logging
> Affects Versions: 3.4.2
> Environment: {code:java}
> ➜ mvn --version
> Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
> Maven home: C:\Users\sbnet\Maven\apache-maven-3.9.9
> Java version: 11.0.24, vendor: Oracle Corporation, runtime: C:\Program
> Files\Java\jdk-11
> Default locale: ru_RU, platform encoding: Cp1251
> OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"{code}
> Reporter: Arut
> Priority: Major
>
> When the *@Context SseEventSink sseEventSink* parameter is added to the
> method, logs are no longer displayed in it. For example, there are some
> exceptions that are visible only during debugging, but there are no logs from
> them. Regular logging via the *LoggerFactory.getLogger* doesn't work in this
> case either.
>
> {code:java}
> @GET
> @Path("/shipMovementSubscribe")
> @Produces(MediaType.SERVER_SENT_EVENTS)
> public void shipMovementSubscribe(@Context Sse sse, @Context SseEventSink
> sseEventSink) {
> java.util.logging.Logger julLogger =
> java.util.logging.Logger.getLogger("org.apache.tomcat.test");
> julLogger.severe("TEST JUL MESSAGE!");
> String link = request.getHeader("gameLink");
> if (link == null || link.isBlank()) {
> throw new BadRequestException("Empty 'gameLink' request header");
> }
> Game game = ...
> SseBroadcaster broadcaster = playersConnectionsMap.get(game.getId());
> if (broadcaster == null) {
> broadcaster = sse.newBroadcaster();
> playersConnectionsMap.put(game.getId(), broadcaster);
> }
> playersConnectionsMap.get(game.getId()).onError(
> (currentSseEventSink, error) -> {
> LOG.error(error.getMessage(), error);
> throw new BadRequestException("Something went wrong while
> executing shipMovementSubscribe");
> });
> broadcaster.register(sseEventSink);
> LOG.info("SUCCESSFUL LOGGING1!");
> ExecutorService executorService = Executors.newSingleThreadExecutor();
> executorService.execute(() -> {
> try (SseEventSink sink = sseEventSink) {
> LOG.info("SUCCESSFUL LOGGING2!");
> }
> });
> if (true) {
> throw new RuntimeException("BUT THIS IS NOT LOGGING!");
> }
> }
> {code}
>
> The messages "{*}CRITICAL TEST JUL MESSAGE!{*}", "{*}SUCCESSFUL LOGGING1!{*}"
> and "{*}SUCCESSFUL LOGGING2!{*}" are printed, but the exception with the
> message "{*}BUT THIS IS NOT LOGGING!{*}" is *not* printed.
> Our *logging dependencies* are as follows:
>
> {code:java}
> <dependency>
> <groupId>ch.qos.logback</groupId>
> <artifactId>logback-classic</artifactId>
> <version>1.2.3</version>
> </dependency>
> <!-- JCL 1.2 Implemented Over SLF4J -->
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>jcl-over-slf4j</artifactId>
> <version>1.7.25</version>
> </dependency>
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>jul-to-slf4j</artifactId>
> <version>1.7.25</version>
> </dependency>
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>log4j-over-slf4j</artifactId>
> <version>1.7.25</version>
> </dependency>
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-api</artifactId>
> <version>1.7.25</version>
> </dependency>
> {code}
>
> We use the following {*}CXF dependencies{*}:
>
> {code:java}
> <dependency>
> <groupId>org.apache.cxf</groupId>
> <artifactId>cxf-rt-frontend-jaxrs</artifactId>
> <version>3.4.2</version>
> </dependency>
> <dependency>
> <groupId>org.apache.cxf</groupId>
> <artifactId>cxf-rt-rs-sse</artifactId>
> <version>3.4.2</version>
> </dependency>
> <dependency>
> <groupId>org.apache.cxf</groupId>
> <artifactId>cxf-rt-transports-http</artifactId>
> <version>3.4.2</version>
> </dependency>
> {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)