File tree Expand file tree Collapse file tree
src/main/java/com/xxl/tool/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ private static String doRequest(String method,
7272 int timeout ) {
7373
7474 HttpURLConnection connection = null ;
75+ DataOutputStream dataOutputStream = null ;
7576 BufferedReader bufferedReader = null ;
7677 try {
7778 // connection
@@ -108,7 +109,7 @@ private static String doRequest(String method,
108109
109110 // write requestBody
110111 if (StringTool .isNotBlank (requestBody )) {
111- DataOutputStream dataOutputStream = new DataOutputStream (connection .getOutputStream ());
112+ dataOutputStream = new DataOutputStream (connection .getOutputStream ());
112113 dataOutputStream .write (requestBody .getBytes (StandardCharsets .UTF_8 ));
113114 dataOutputStream .flush ();
114115 dataOutputStream .close ();
@@ -135,6 +136,9 @@ private static String doRequest(String method,
135136 throw new RuntimeException ("Http Request Error (" + e .getMessage () +"). for url : " + url );
136137 } finally {
137138 try {
139+ if (dataOutputStream != null ) {
140+ dataOutputStream .close ();
141+ }
138142 if (bufferedReader != null ) {
139143 bufferedReader .close ();
140144 }
You can’t perform that action at this time.
0 commit comments