Forráskód Böngészése

fix(backend): WechatService 用 StreamUtils.copyToByteArray 替代 readAllBytes,兼容 Java 8 编译

iwt 1 hónapja
szülő
commit
72bb3c0f93

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/service/WechatService.java

@@ -11,6 +11,7 @@ import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
+import org.springframework.util.StreamUtils;
 import com.etotem.cfc.service.api.WechatServiceInterface;
 
 import javax.annotation.PostConstruct;
@@ -344,7 +345,7 @@ public class WechatService implements WechatServiceInterface {
             os.close();
 
             InputStream is = conn.getInputStream();
-            byte[] responseBytes = is.readAllBytes();
+            byte[] responseBytes = StreamUtils.copyToByteArray(is);
             is.close();
             String responseBody = new String(responseBytes, StandardCharsets.UTF_8);