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

Fix for #118: Fixed NPE in SonarDevon4jPlugin class #120

Merged
merged 16 commits into from
Dec 17, 2020

Conversation

lmarniazman
Copy link
Member

@lmarniazman lmarniazman commented Dec 17, 2020

Fixes #118

Added an if-condition checking if the array fileList is null. If yes, it is not used to fill pluginList with values, instead an empty ArrayList is returned.

Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@lmarniazman thanks for your quick fix. I am approving as merging this PR increases the quality and is fine for me, but our plugin might still be buggy even with this PR merged.

Comment on lines -66 to +70
this.pluginList = Arrays.asList(fileList).stream().map(f -> f.getName()).collect(Collectors.toList());
if (fileList != null) {
this.pluginList = Arrays.asList(fileList).stream().map(f -> f.getName()).collect(Collectors.toList());
} else {
this.pluginList = new ArrayList<>();
}
Copy link
Member

Choose a reason for hiding this comment

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

OK, so fileList may be null and you are checking for this. This is a strange API of Java JDK, but indeed this can be null if already the directory (this.pluginDirectory) does not exist:
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#listFiles(java.io.FileFilter)

So there must be another error if that directory does not exist. With this fix, we will prevent NPE but wont be able to detect the plugins as the pluginsDirectory seems to be determined wrong.

@@ -17,7 +17,7 @@

private static final String DISABLED = "Disabled";

private static final String QUALINSIGHT = "qualinsight-plugins-sonarqube-smell-plugin";
private static final String QUALINSIGHT = "qualinsight-sonarqube-smell-plugin";
Copy link
Member

Choose a reason for hiding this comment

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

was this wrong from the start or has that plugin be renamed and the name might depend on the version of SonarQube server?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@lmarniazman lmarniazman Dec 17, 2020

Choose a reason for hiding this comment

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

The naming of this plugin is a little inconsistent... Most of the released versions are using qualinsight-sonarqube-smell-plugin, except for 3.0.0 & 2.0.0-RC2 (see releases)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for that explanation. It might have been better then to implement some magic in our plugin that will try both names and see if one of them works. We might break existing installations using the old name with this change...

@hohwille hohwille added this to the release:2020.12.002 milestone Dec 17, 2020
@hohwille hohwille added bug dependencies Pull requests that update a dependency file enhancement labels Dec 17, 2020
@hohwille
Copy link
Member

I will merge this now, but my comments indicate that IMHO #118 is not properly fixed. We only prevent NPE now but the root of the problem is IMHO still present.

@hohwille hohwille merged commit 3bd6482 into devonfw:master Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependencies Pull requests that update a dependency file enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project analysis fails and throws Nullpointer
2 participants