You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "xcx1r3 (via GitHub)" <gi...@apache.org> on 2025/05/27 02:47:14 UTC

[I] Potential resource leakage in WordDictionary#loadMainDataFromFile [lucene]

xcx1r3 opened a new issue, #14719:
URL: https://github.com/apache/lucene/issues/14719

   ### Description
   
   In `org.apache.lucene.analysis.cn.smart.hhmm.WordDictionary#loadMainDataFromFile`, the resouce `DataInputStream dctFile` could be leaked upon exception.
   It can be fixed by using the try-with-resources construct.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Potential resource leakage in WordDictionary#loadMainDataFromFile [lucene]

Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz closed issue #14719: Potential resource leakage in WordDictionary#loadMainDataFromFile
URL: https://github.com/apache/lucene/issues/14719


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Potential resource leakage in WordDictionary#loadMainDataFromFile [lucene]

Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz commented on issue #14719:
URL: https://github.com/apache/lucene/issues/14719#issuecomment-2913817299

   Good catch, would you like to submit a PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Potential resource leakage in WordDictionary#loadMainDataFromFile [lucene]

Posted by "xcx1r3 (via GitHub)" <gi...@apache.org>.
xcx1r3 commented on issue #14719:
URL: https://github.com/apache/lucene/issues/14719#issuecomment-2914834339

   #14726  sure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Potential resource leakage in WordDictionary#loadMainDataFromFile [lucene]

Posted by "xcx1r3 (via GitHub)" <gi...@apache.org>.
xcx1r3 commented on issue #14719:
URL: https://github.com/apache/lucene/issues/14719#issuecomment-2911474550

   if an exception occur, the close() statement will not be executed, leading to a potential resource leak.
   ```
   private int loadMainDataFromFile(String dctFilePath) throws IOException {
       int i, cnt, length, total = 0;
       // The file only counted 6763 Chinese characters plus 5 reserved slots 3756~3760.
       // The 3756th is used (as a header) to store information.
       int[] buffer = new int[3];
       byte[] intBuffer = new byte[4];
       String tmpword;
       DataInputStream dctFile = new DataInputStream(Files.newInputStream(Paths.get(dctFilePath)));
       ....
       dctFile.close();


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Potential resource leakage in WordDictionary#loadMainDataFromFile [lucene]

Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz commented on issue #14719:
URL: https://github.com/apache/lucene/issues/14719#issuecomment-2930382910

   Fixed via #14727


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org