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

NPE during Report Generation with SonarQube 9.9.1.69595 #415

Open
Zuplyx opened this issue Sep 13, 2024 · 1 comment
Open

NPE during Report Generation with SonarQube 9.9.1.69595 #415

Zuplyx opened this issue Sep 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Zuplyx
Copy link

Zuplyx commented Sep 13, 2024

Describe the bug

Report creation fails with a NullPointerException.

To reproduce

Steps to reproduce the behavior.

Run the standalone jar:
java -jar sonar-cnes-report-4.3.0.jar -p PROJECT_KEY -b trunk -s http://SERVER_URL:8090/

Expected behavior

A clear and concise description of what you expected to happen.

The report should complete successfully.

Screenshots & log

Stacktrace:

Exception in thread "main" java.lang.NullPointerException
        at fr.cnes.sonar.report.providers.facets.AbstractFacetsProvider.extractTimeValuesFromJsonObject(AbstractFacetsProvider.java:176)
        at fr.cnes.sonar.report.providers.facets.AbstractFacetsProvider.getTimeFacetsAbstract(AbstractFacetsProvider.java:143)
        at fr.cnes.sonar.report.providers.facets.FacetsProviderStandalone.getTimeFacets(FacetsProviderStandalone.java:65)
        at fr.cnes.sonar.report.factory.ReportModelFactory.create(ReportModelFactory.java:121)
        at fr.cnes.sonar.report.ReportCommandLine.execute(ReportCommandLine.java:145)
        at fr.cnes.sonar.report.ReportCommandLine.main(ReportCommandLine.java:82)

According to the stacktrace the report creation fails in fr.cnes.sonar.report.providers.facets.AbstractFacetsProvider#extractTimeValuesFromJsonObject when trying to process this json {"date":"2012-01-01T00:11:23+0100"}

User environment

Please complete the following information.

  • OS: [Windows 11]
  • Project version: [4.3.0]

Proposed fix:

Applying the following patch fixes the issue:

diff --git a/src/main/java/fr/cnes/sonar/report/providers/facets/AbstractFacetsProvider.java b/src/main/java/fr/cnes/sonar/report/providers/facets/AbstractFacetsProvider.java
index 7a38c15..111e98d 100644
--- a/src/main/java/fr/cnes/sonar/report/providers/facets/AbstractFacetsProvider.java
+++ b/src/main/java/fr/cnes/sonar/report/providers/facets/AbstractFacetsProvider.java
@@ -169,11 +169,12 @@ public abstract class AbstractFacetsProvider extends AbstractDataProvider {
         // For each measure (date/value) inside the "history" attribute of the measure
         for(JsonElement history : metric.get(HISTORY).getAsJsonArray()) {
             JsonObject measure = history.getAsJsonObject();
+            // Get data as String because Word charts take Strings as input
+            String value = measure.get("date").getAsString();
             // Convert Date from SonarQube format to Excel
             double date = DateConverter.sonarQubeDateToExcelDate(
-                measure.get("date").getAsString());
-            // Get data as String because Word charts take Strings as input
-            String value = measure.get("value").getAsString();
+                value);
+
             TimeValue v = new TimeValue(date, value);
             values.add(v);
         }
@Zuplyx Zuplyx added the bug Something isn't working label Sep 13, 2024
@Zuplyx
Copy link
Author

Zuplyx commented Sep 17, 2024

After an update to the most recent LTS version (9.9.6.92038) of SonarQube this issue still persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant