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

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git

commit e028b2072d688db59b81087ca5138b02465d36bf
Author: Robert Lazarski <[email protected]>
AuthorDate: Sat Sep 5 04:44:44 2026 -1000

    Release the redirect probe's connection in codegen
    
    The probe reads the status line and one header, so the body is never 
consumed
    and the socket cannot return to the keep-alive pool by itself. wsdl2java 
also
    runs from the ant task and the wsdl2code maven plugin, generating for many
    WSDLs in one build JVM, so disconnect() in a finally block rather than 
waiting
    on finalization.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
---
 .../axis2/wsdl/codegen/CodeGenConfiguration.java   | 26 +++++++++++++++-------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git 
a/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java 
b/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
index 17815f90bb..c2de9046f4 100644
--- 
a/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
+++ 
b/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
@@ -752,14 +752,24 @@ public class CodeGenConfiguration implements 
CommandLineOptionConstants {
             if (requestUrl != null) {
                 HttpURLConnection connection =
                         (HttpURLConnection) requestUrl.openConnection();
-                connection.setInstanceFollowRedirects(false);
-                connection.setConnectTimeout(REDIRECT_CONNECT_TIMEOUT);
-                connection.setReadTimeout(REDIRECT_READ_TIMEOUT);
-                int responseCode = connection.getResponseCode();
-                String newLocation = redirectTarget(requestUrl, responseCode,
-                        connection.getHeaderField("Location"));
-                if (newLocation != null) {
-                    wsdlUri = newLocation;
+                try {
+                    connection.setInstanceFollowRedirects(false);
+                    connection.setConnectTimeout(REDIRECT_CONNECT_TIMEOUT);
+                    connection.setReadTimeout(REDIRECT_READ_TIMEOUT);
+                    int responseCode = connection.getResponseCode();
+                    String newLocation = redirectTarget(requestUrl, 
responseCode,
+                            connection.getHeaderField("Location"));
+                    if (newLocation != null) {
+                        wsdlUri = newLocation;
+                    }
+                } finally {
+                    // The probe wants the status line and one header, so the 
body is
+                    // never read and the socket cannot go back to the 
keep-alive pool
+                    // on its own. wsdl2java also runs from the ant task and 
the
+                    // wsdl2code maven plugin, inside a build JVM that 
generates for
+                    // many WSDLs in a row, so releasing it here rather than 
leaving
+                    // it to finalization matters more than it would in the 
CLI.
+                    connection.disconnect();
                 }
             }
 

Reply via email to