org.json.JSONTokener should close or provide option to close java.io.Reader
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- java
研究方向
Start by reading org.json.JSONTokener and the JavaDoc describing responsibility for closing the supplied Reader. Determine whether the intended change is automatic closing or an explicit close option, then inspect existing tests or add coverage for the chosen reader-lifecycle behavior.
由索引模型根據 Issue 內容生成。
描述
Hi,
I spent a few days trying to fix an issue where I got the following error:
java.nio.file.FileSystemException: path/to/file: The process cannot access the file because it is being used by another process.
I started using FileLock to try to get a hold on the lock and wait until the lock was released, but unfortunately for this file, it would never be released.
That is because I was using a JSONTokener to tokenize a JSON file using an anonymous FileReader. This stream would never be closed, and therefor the error mentioned above.
Because JSONTokener doesn't provide an API to close the stream provided as parameter, I have to correct my implementation like this:
Obviously after reading the class it is clear how it should be used, since it is clearly written in the JavaDoc that the Reader must be closed by the caller.
I believe this implementation could be improved.
- Implement Closeable/AutoClosable on JSONTokener and make JSONTokener throw some sort of exception to explicitly tell the user that the Reader must be closed. And then we could have a cleaner and more explicit implementation like this:
Let me know if my suggestion is outrageous. But I feel at least I should bring it here.
Thank you for your attention. :)
- 主要語言
- Java
- 星號
- 4.7k
- 分支
- 2.6k
- 平均合併
- 4 天 11 小時
- 30 天內合併 PR
- 7
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
stleary/JSON-java 的其他 Issue
-
JSONObject.toString does not use an Enum's `toString()` but its `name()`可能重新可做 @XIAYM-gh 於 43 天前認領,目前沒有進行中的 PR。 未關閉Fix before the next release
難度 2/5 1-3 小時 新手友好度 78/100
-
Awaiting further input from submitter No changes at this time
難度 3/5 1-2 天 新手友好度 45/100
-
Investigating
難度 5/5 一週以上 新手友好度 45/100
-
難度 3/5 1-2 天 新手友好度 72/100
-
Active discussion
難度 5/5 一週以上 新手友好度 35/100
查看 stleary/JSON-java 的全部 Issue
相似的 Issue
-
Triage
難度 2/5 1-3 小時 新手友好度 75/100
MinecraftForge/MinecraftForge#10902 · 1 則留言 ·
-
bug
難度 2/5 1-3 小時 新手友好度 74/100
refinedmods/refinedstorage2#1421 ·
-
StepExamBenchmarkTest runs a loop and prints a timing but asserts nothing可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉jules
難度 1/5 1 小時以內 新手友好度 82/100
open-learning-exchange/myplanet#18199 · 1 則留言 ·
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
Scheme-less stream URLs throw NullPointerException instead of URISyntaxException可能已有人在做 @blihio 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
pedroSG94/RootEncoder#2218 ·
維護者通常 3 天內回覆