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

CXF-9095 fix connection leak #2219

Conversation

suxuan-king1
Copy link

No description provided.

Copy link
Contributor

@ffang ffang left a comment

Choose a reason for hiding this comment

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

Hi @suxuan-king1 ,

How about we put all potential resources check and close in one final block, something like this

-            super.close();
-            if (pout != null) {
-                pout.close();
-                pout = null;
-            }
-            if (publisher != null) {
-                publisher.close();
-                publisher = null;
+            try {
+                super.close();
+            } finally {
+                if (pout != null) {
+                    try {
+                        pout.close();
+                    } catch (IOException e) {
+                        logStackTrace(e);
+                    }
+                    pout = null;
+                }
+                if (publisher != null) {
+                    try {
+                        publisher.close();
+                    } catch (IOException e) {
+                        logStackTrace(e);
+                    }
+                    publisher = null;
+                }
+                request = null;
+                subscribers = null;
             }
-            request = null;
-            subscribers = null;
+            
+            

Freeman

@ffang
Copy link
Contributor

ffang commented Jan 13, 2025

Hi @suxuan-king1 ,

Could you please revise your PR accordingly as we discussed?

Also, please send your revised PR against cxf:main branch

Thanks!
Freeman

@suxuan-king1 suxuan-king1 deleted the fix-connection-leak-cxf-9095 branch January 24, 2025 06:22
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.

2 participants