Commit 0c2c87d42c2fedd074d0a90c0425dca2f6ecfe37
1 parent
df57349b
okhttp返回非200的结果时手动关闭response
Showing
1 changed file
with
7 additions
and
0 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| ... | ... | @@ -55,6 +55,9 @@ public class ZLMRESTfulUtils { |
| 55 | 55 | if (responseStr != null) { |
| 56 | 56 | responseJSON = JSON.parseObject(responseStr); |
| 57 | 57 | } |
| 58 | + }else { | |
| 59 | + response.close(); | |
| 60 | + Objects.requireNonNull(response.body()).close(); | |
| 58 | 61 | } |
| 59 | 62 | } catch (ConnectException e) { |
| 60 | 63 | logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); |
| ... | ... | @@ -74,6 +77,10 @@ public class ZLMRESTfulUtils { |
| 74 | 77 | } catch (IOException e) { |
| 75 | 78 | logger.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); |
| 76 | 79 | } |
| 80 | + | |
| 81 | + }else { | |
| 82 | + response.close(); | |
| 83 | + Objects.requireNonNull(response.body()).close(); | |
| 77 | 84 | } |
| 78 | 85 | } |
| 79 | 86 | ... | ... |