|
|
@@ -90,6 +90,7 @@ public class BaiduChatUtils {
|
|
|
public void sendBaiduAiStream(InputSendChat inputSendChat) throws IOException {
|
|
|
SseResult res = null;
|
|
|
BufferedReader reader=null;
|
|
|
+ InputStreamReader inputStreamReader=null;
|
|
|
try {
|
|
|
String baidu_url=BAIDU_CHAT_WXYY_URL+getRedisBaiduAccessToken();
|
|
|
URL url = new URL(baidu_url);
|
|
|
@@ -105,7 +106,8 @@ public class BaiduChatUtils {
|
|
|
connection.setRequestProperty("Content-Length", String.valueOf(postData.length));
|
|
|
connection.getOutputStream().write(postData);
|
|
|
InputStream responseStream = connection.getInputStream();
|
|
|
- reader = new BufferedReader(new InputStreamReader(responseStream,"UTF-8"));
|
|
|
+ inputStreamReader = new InputStreamReader(responseStream, "UTF-8");
|
|
|
+ reader = new BufferedReader(inputStreamReader);
|
|
|
String line;
|
|
|
res = SseMap.sseEmitterMap.get(inputSendChat.getUserId());
|
|
|
while ((line = reader.readLine())!= null) {
|
|
|
@@ -148,6 +150,7 @@ public class BaiduChatUtils {
|
|
|
}catch (IllegalStateException e){
|
|
|
LoggerUtils.debug(getClass(),"前端网页已关闭");
|
|
|
}finally {
|
|
|
+ inputStreamReader.close();
|
|
|
reader.close();
|
|
|
res.sseEmitter.complete();
|
|
|
SseMap.sseEmitterMap.remove(inputSendChat.getUserId());
|