fix: close leaked HTTP client in getHttpClientResponse()#792
Conversation
Signed-off-by: ayuxsh009 <1raj.aayush@gmail.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fix: close leaked HTTP client in getHttpClientResponse()
Summary
Fixes an HTTP resource leak in
MosipDeviceSpecificationHelper#getHttpClientResponse()where a new
CloseableHttpClientwas created for every MDM request but never closed.This affected stream, rcapture, and device info operations for spec
0.9.5devices and could progressively exhaust JVM socket/file descriptors during
normal registration sessions.
Fixes #791
Root Cause
getHttpClientResponse()returned a rawCloseableHttpResponsewhile theinternally created
CloseableHttpClientremained unmanaged.Because the client lifecycle was detached from the caller, sockets and HTTP
connections accumulated over repeated biometric operations.
Fix
Changed the method return type from
CloseableHttpResponsetoInputStream.The method now:
FilterInputStreamCloseableHttpResponseandCloseableHttpClientwhen the stream is closed
IOExceptionbefore rethrowingUpdated the only caller in
MosipDeviceSpecification_095_ProviderImplto consumeInputStreamdirectly and removed the unused
CloseableHttpResponseimport.Files Changed
MosipDeviceSpecificationHelper.javaInputStreamMosipDeviceSpecification_095_ProviderImpl.javaBioServiceTest.java204 No Contenthandling test