Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-5031 UpgradeUtil may not close a stream #2107

Merged
merged 1 commit into from
Apr 24, 2017

Conversation

JudeNiroshan
Copy link
Contributor

Description of what I changed

UpgradeUtil may not close a stream.

Wrapped PreparedStatements into try-with-resources as well in order to simplify and close the preparedStatement automatically.

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-5031

Checklist: I completed these to help reviewers :)

  • My pull request only contains ONE single commit
    (the number above, next to the 'Commits' tab is 1).

    No? -> read here on how to squash multiple commits into one

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

Test cases were not changed. Can not add a new test case to capture the scenario of UpgradeUtil#getConceptIdForUnits getting the file stream being opened as there is no way to throw an runtime exception through the test case. Properties#load(StringReader) doesn't allow null to be as values. Default it empty string.

No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@mention-bot
Copy link

@JudeNiroshan, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bmamlin and @tomaszmueller to be potential reviewers.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 56.126% when pulling 3e9defd on JudeNiroshan:TRUNK-5031 into e2a5df5 on openmrs:master.

try {
FileInputStream fis = new FileInputStream(appDataDir + System.getProperty("file.separator")
+ DatabaseUtil.ORDER_ENTRY_UPGRADE_SETTINGS_FILENAME);
String filePath = new StringBuilder(appDataDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JudeNiroshan dont extract this temp variable. just move the fis into the try-with resource like you did in the other cases.

@teleivo
Copy link
Member

teleivo commented Apr 18, 2017

@JudeNiroshan can you please make my requested change so I can merge this. thank you!

@wluyima wluyima merged commit b99cdc8 into openmrs:master Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants