Trouble with try-catch-finally


#1

Hi,

Since a couple of days, our company has introduced SonarQube on Android projects. Many issues have been solved already, except for one case: surrounding a FileOutputStream() object with try-catch-finally.

Before, the FileOutputStream() was not guarded with the try-catch-finally construction (note: we can’t use the try-with-rescources alternative since the API level used is 18 and should be 19+ for this alternative), so SonarQube/SonarLint was right in indicating it as a critical bug. Result: I guarded the construction as it should be guarded.

However, even if the guard is present and correctly implemented, SonarQube is still telling me to guard it like so:

Snapshot of code with issue underlined by SonarQube/SonarLint:

Oops… I wanted to post two more images but apparently new users can only post one image per post. Strange…
I will post the other 2 images in replies to this post, so pls. also check those.

I simply don’t understand as to why SonarQube/SonarLint still tells me to do something I already did…

Can someone shed a light on what else (if possible) has to be done?

Many thanks,

Best,
–Geert


#2

As promised, the second image showing a snapshot of the SonarQube/SonarLint tooltip:

Best,
–Geert


#3

And here’s the third image I wanted to post on my first post: snapshot of SonarLint message regarding the issue I mentioned earlier:

Hope someone can help me out of this…

Best,
–Geert


#4

This is sonar, the billing software. I think you may have posted in the wrong website.


#5

Oops… That was not the intention… Sorry for that. Will move over to the community forum. Thanks for warning.

Best,
–Geert