iTXTech / mirai-native

强大的 mirai 原生插件加载器
GNU Affero General Public License v3.0
371 stars 141 forks source link

调用CQ_getImage()后出现报错 #140

Closed zxin8580 closed 3 years ago

zxin8580 commented 3 years ago

描述这个Bug getImage似乎不会释放线程和资源,会导致线程数持续增加,一定时间后mirai崩溃

复现步骤 在收到消息出现图片时调用getImage取回图片路径

期望的行为 资源得到释放

截图和日志 2021-06-02 11:01:02 E/MiraiNative: Error occurred when plugin "co.unclesiege.tinystar" (tinystar.dll) (ID: 0) downloading image {5A76B500-81AC-084D-A0C1-F8F60F79E56D}.jpg.mnimg java.io.IOException: unexpected end of stream on http://gchat.qpic.cn/... at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:202) at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.io.EOFException: \n not found: limit=0 content=… at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:348) at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29) at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178) ... 16 more

运行环境

更多信息 在任务管理器→性能→资源监视器中:可以看见无论是否报错,每调用一次getImage()都将增加10个线程左右且不会自动释放,长时间后将到达线程上限,然后因线程启动失败停止处理消息