Skip to content

Commit

Permalink
fix: guard close with null-check to avoid NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
miurahr committed May 16, 2024
1 parent ccb2a83 commit c171a95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This repository is a forked jmyspell-core project used for OmegaT project.
- use `isEmpty()` for condition that compare with zero length
- fix: define `Word#hashCode`, `Word` class already has `equals` definition
- fix: unwanted raw types
- fix: check nullity of stream before close
- style: apply spotbugs
- Quality assurance by checking with SpotBugs static code analysis
- CI: test with GitHub Actions
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/dts/spell/dictionary/myspell/MySpell.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ else if (entry.getName().endsWith(".dic"))
dStream = zipFile.getInputStream(entry) ;
}

initFromStreams(affStream, dStream) ;

affStream.close() ;
dStream.close() ;
initFromStreams(affStream, dStream) ;

if (affStream != null) {
affStream.close() ;
}
if (dStream != null) {
dStream.close() ;
}
}

public MySpell(InputStream zipStream) throws IOException
Expand Down

0 comments on commit c171a95

Please sign in to comment.