Commit c62c66edefbb764b23d239defb26a34149b5868e

Authored by 648540858
1 parent 80bfd9ce

去除调试日志

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
@@ -29,7 +29,6 @@ public class ZLMRESTfulUtils { @@ -29,7 +29,6 @@ public class ZLMRESTfulUtils {
29 OkHttpClient client = new OkHttpClient(); 29 OkHttpClient client = new OkHttpClient();
30 String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); 30 String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api);
31 JSONObject responseJSON = null; 31 JSONObject responseJSON = null;
32 - logger.debug(url);  
33 32
34 FormBody.Builder builder = new FormBody.Builder(); 33 FormBody.Builder builder = new FormBody.Builder();
35 builder.add("secret",mediaServerItem.getSecret()); 34 builder.add("secret",mediaServerItem.getSecret());
@@ -51,8 +50,9 @@ public class ZLMRESTfulUtils { @@ -51,8 +50,9 @@ public class ZLMRESTfulUtils {
51 try { 50 try {
52 Response response = client.newCall(request).execute(); 51 Response response = client.newCall(request).execute();
53 if (response.isSuccessful()) { 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 responseJSON = JSON.parseObject(responseStr); 56 responseJSON = JSON.parseObject(responseStr);
57 } 57 }
58 }else { 58 }else {
@@ -100,7 +100,11 @@ public class ZLMRESTfulUtils { @@ -100,7 +100,11 @@ public class ZLMRESTfulUtils {
100 public void sendGetForImg(MediaServerItem mediaServerItem, String api, Map<String, Object> params, String targetPath, String fileName) { 100 public void sendGetForImg(MediaServerItem mediaServerItem, String api, Map<String, Object> params, String targetPath, String fileName) {
101 String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); 101 String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api);
102 logger.debug(url); 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 httpBuilder.addQueryParameter("secret", mediaServerItem.getSecret()); 109 httpBuilder.addQueryParameter("secret", mediaServerItem.getSecret());
106 if (params != null) { 110 if (params != null) {
@@ -123,16 +127,25 @@ public class ZLMRESTfulUtils { @@ -123,16 +127,25 @@ public class ZLMRESTfulUtils {
123 if (targetPath != null) { 127 if (targetPath != null) {
124 File snapFolder = new File(targetPath); 128 File snapFolder = new File(targetPath);
125 if (!snapFolder.exists()) { 129 if (!snapFolder.exists()) {
126 - snapFolder.mkdirs(); 130 + if (!snapFolder.mkdirs()) {
  131 + logger.warn("{}路径创建失败", snapFolder.getAbsolutePath());
  132 + }
  133 +
127 } 134 }
128 File snapFile = new File(targetPath + "/" + fileName); 135 File snapFile = new File(targetPath + "/" + fileName);
129 FileOutputStream outStream = new FileOutputStream(snapFile); 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 outStream.close(); 141 outStream.close();
132 } else { 142 } else {
133 logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); 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 } else { 149 } else {
137 logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); 150 logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message()));
138 } 151 }