Repository navigation
Make sure files are closed correctly - #3023
DavyLandman wants to merge 3 commits into
Conversation
…than needed to close a file
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3023 +/- ##
=======================================
Coverage 46% 46%
+ Complexity 6936 6935 -1
=======================================
Files 851 851
Lines 69360 69336 -24
Branches 10110 10104 -6
=======================================
- Hits 32179 32174 -5
+ Misses 34745 34728 -17
+ Partials 2436 2434 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if (exists(file)) { | ||
| try { | ||
| byte[] bytes = Prelude.consumeInputStream(getInputStream(file)); | ||
| try (var classContents = getInputStream(file)) { |
There was a problem hiding this comment.
here is the bugfix for the class loader leaking input stream handle.
| private static ColumnMaps initColumnMaps() { | ||
| return new ColumnMaps(loc -> { | ||
| return Prelude.consumeInputStream(URIResolverRegistry.getInstance().getCharacterReader(loc.top())); | ||
| try (var contents = URIResolverRegistry.getInstance().getCharacterReader(loc.top())) { |
There was a problem hiding this comment.
this is the bugfix for the issue reported in rascal-language-servers
PieterOlivier
left a comment
There was a problem hiding this comment.
Nice fixes and code cleanup by reusing existing methods.
008e6fb to
5447bac
Compare
|
toinehartman
left a comment
There was a problem hiding this comment.
Nice safety improvements and code size reduction.
| */ | ||
|
|
||
| public IInteger getFileLength(ISourceLocation g) { | ||
| if (g.getScheme().equals("file")) { |
There was a problem hiding this comment.
Do we not need the special case for file anymore?
There was a problem hiding this comment.
Nope, this all happens inside the URIResolverRegistry now. Automatically.



Diagnosing usethesource/rascal-language-servers#1276 pointed to a file-handle leak in the
ColumnMapsloader function. After that change I've reviewed all uses ofgetCharacterReaderandgetInputStreamand fixed a few more cases. For example our class loader would leak file handles until the GC came around.I also rewrite a few others to use try-with-resources just so that its clear it's always handled correctly (and reduces the code size around that ceremony of closing and catching the exceptions on close etc).
Fixes usethesource/rascal-language-servers#1276