Commit c62c66edefbb764b23d239defb26a34149b5868e
1 parent
80bfd9ce
去除调试日志
Showing
1 changed file
with
20 additions
and
7 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| ... | ... | @@ -29,7 +29,6 @@ public class ZLMRESTfulUtils { |
| 29 | 29 | OkHttpClient client = new OkHttpClient(); |
| 30 | 30 | String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); |
| 31 | 31 | JSONObject responseJSON = null; |
| 32 | - logger.debug(url); | |
| 33 | 32 | |
| 34 | 33 | FormBody.Builder builder = new FormBody.Builder(); |
| 35 | 34 | builder.add("secret",mediaServerItem.getSecret()); |
| ... | ... | @@ -51,8 +50,9 @@ public class ZLMRESTfulUtils { |
| 51 | 50 | try { |
| 52 | 51 | Response response = client.newCall(request).execute(); |
| 53 | 52 | if (response.isSuccessful()) { |
| 54 | - String responseStr = response.body().string(); | |
| 55 | - if (responseStr != null) { | |
| 53 | + ResponseBody responseBody = response.body(); | |
| 54 | + if (responseBody != null) { | |
| 55 | + String responseStr = responseBody.string(); | |
| 56 | 56 | responseJSON = JSON.parseObject(responseStr); |
| 57 | 57 | } |
| 58 | 58 | }else { |
| ... | ... | @@ -100,7 +100,11 @@ public class ZLMRESTfulUtils { |
| 100 | 100 | public void sendGetForImg(MediaServerItem mediaServerItem, String api, Map<String, Object> params, String targetPath, String fileName) { |
| 101 | 101 | String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); |
| 102 | 102 | logger.debug(url); |
| 103 | - HttpUrl.Builder httpBuilder = HttpUrl.parse(url).newBuilder(); | |
| 103 | + HttpUrl parseUrl = HttpUrl.parse(url); | |
| 104 | + if (parseUrl == null) { | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + HttpUrl.Builder httpBuilder = parseUrl.newBuilder(); | |
| 104 | 108 | |
| 105 | 109 | httpBuilder.addQueryParameter("secret", mediaServerItem.getSecret()); |
| 106 | 110 | if (params != null) { |
| ... | ... | @@ -123,16 +127,25 @@ public class ZLMRESTfulUtils { |
| 123 | 127 | if (targetPath != null) { |
| 124 | 128 | File snapFolder = new File(targetPath); |
| 125 | 129 | if (!snapFolder.exists()) { |
| 126 | - snapFolder.mkdirs(); | |
| 130 | + if (!snapFolder.mkdirs()) { | |
| 131 | + logger.warn("{}路径创建失败", snapFolder.getAbsolutePath()); | |
| 132 | + } | |
| 133 | + | |
| 127 | 134 | } |
| 128 | 135 | File snapFile = new File(targetPath + "/" + fileName); |
| 129 | 136 | FileOutputStream outStream = new FileOutputStream(snapFile); |
| 130 | - outStream.write(response.body().bytes()); | |
| 137 | + ResponseBody responseBody = response.body(); | |
| 138 | + if (responseBody != null) { | |
| 139 | + outStream.write(responseBody.bytes()); | |
| 140 | + } | |
| 131 | 141 | outStream.close(); |
| 132 | 142 | } else { |
| 133 | 143 | logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); |
| 134 | 144 | } |
| 135 | - response.body().close(); | |
| 145 | + ResponseBody responseBody = response.body(); | |
| 146 | + if (responseBody != null) { | |
| 147 | + responseBody.close(); | |
| 148 | + } | |
| 136 | 149 | } else { |
| 137 | 150 | logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); |
| 138 | 151 | } | ... | ... |