@@ -68,6 +68,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType) throws
68
68
public static ReturnT postBody (String url , String accessToken , int timeout , Object requestObj , Class returnTargClassOfT ) {
69
69
HttpURLConnection connection = null ;
70
70
BufferedReader bufferedReader = null ;
71
+ DataOutputStream dataOutputStream = null ;
71
72
try {
72
73
// connection
73
74
URL realUrl = new URL (url );
@@ -102,7 +103,7 @@ public static ReturnT postBody(String url, String accessToken, int timeout, Obje
102
103
if (requestObj != null ) {
103
104
String requestBody = GsonTool .toJson (requestObj );
104
105
105
- DataOutputStream dataOutputStream = new DataOutputStream (connection .getOutputStream ());
106
+ dataOutputStream = new DataOutputStream (connection .getOutputStream ());
106
107
dataOutputStream .write (requestBody .getBytes ("UTF-8" ));
107
108
dataOutputStream .flush ();
108
109
dataOutputStream .close ();
@@ -144,6 +145,9 @@ public static ReturnT postBody(String url, String accessToken, int timeout, Obje
144
145
return new ReturnT <String >(ReturnT .FAIL_CODE , "xxl-job remoting error(" + e .getMessage () +"), for url : " + url );
145
146
} finally {
146
147
try {
148
+ if (dataOutputStream != null ) {
149
+ dataOutputStream .close ();
150
+ }
147
151
if (bufferedReader != null ) {
148
152
bufferedReader .close ();
149
153
}
0 commit comments