You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2020/12/13 16:14:15 UTC

[cxf] branch 3.4.x-fixes updated: CXF-7988: SSE sink warning on tomcat

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.4.x-fixes by this push:
     new 62d66b4  CXF-7988: SSE sink warning on tomcat
62d66b4 is described below

commit 62d66b4d4a4c6dd3909835960b47197ce7719e05
Author: reta <dr...@gmail.com>
AuthorDate: Sun Dec 13 10:02:34 2020 -0500

    CXF-7988: SSE sink warning on tomcat
    
    (cherry picked from commit c239bd3b18253fbdaf9b2bd2322a29452d5473d6)
---
 .../java/org/apache/cxf/jaxrs/sse/SseEventSinkImpl.java    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseEventSinkImpl.java b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseEventSinkImpl.java
index d515e84..9e2c88f 100644
--- a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseEventSinkImpl.java
+++ b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseEventSinkImpl.java
@@ -146,7 +146,7 @@ public class SseEventSinkImpl implements SseEventSink {
                         ctx.complete();
                     }
                 } catch (final IllegalStateException ex) {
-                    LOG.warning("Failed to close the AsyncContext cleanly: " + ex.getMessage());
+                    LOG.fine("Failed to close the AsyncContext cleanly: " + ex.getMessage());
                 }
             }
             
@@ -264,17 +264,19 @@ public class SseEventSinkImpl implements SseEventSink {
             // it inside the onError() callback. However, most of the servlet containers
             // do not handle this case properly (and onError() is not called). 
             if (shouldComplete && completed.compareAndSet(false, true)) {
-                LOG.warning("Prematurely completing the AsyncContext due to error encountered: " + error);
+                LOG.fine("Prematurely completing the AsyncContext due to error encountered: " + error);
                 // In case of Tomcat, the context is closed automatically when client closes
                 // the connection and onError callback will be called (in this case request 
                 // is set to null).
-                if (ctx.getRequest() != null) {
+                try {
                     LOG.fine("Completing the AsyncContext");
-                    try {
+                    // Older versions of Tomcat returned 'null', now the getRequest() throws
+                    // IllegalStateException if it is 'null'.
+                    if (ctx.getRequest() != null) {
                         ctx.complete();
-                    } catch (final IllegalStateException ex) {
-                        LOG.warning("Failed to close the AsyncContext cleanly: " + ex.getMessage());
                     }
+                } catch (final IllegalStateException ex) {
+                    LOG.fine("Failed to close the AsyncContext cleanly: " + ex.getMessage());
                 }
             }
         }