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

HTML Reporter throwing null pointer error (NPE) #146

Closed
DSEyers opened this issue Feb 6, 2020 · 23 comments
Closed

HTML Reporter throwing null pointer error (NPE) #146

DSEyers opened this issue Feb 6, 2020 · 23 comments

Comments

@DSEyers
Copy link

DSEyers commented Feb 6, 2020

Getting NPE when request Clover to generate HTML file. If set to false can get XML file fine.

MacOS Catalina - version 10.15.3

build.gradle snippet
// Declare Gradle plugins to be used
plugins {
id 'eclipse' // Add support for Eclipse
id 'findbugs' // FindBugs plugin: http://findbugs.sourceforge.net/
id 'java-library' // Add support for building Java libraries
id 'com.bmuschko.clover' version '2.2.4' // Add coverage reporting
}

dependencies {
// Project resources
implementation(
// External resources
'org.apache.commons:commons-lang3:3.9',
'org.apache.logging.log4j:log4j-api:2.8.2',
'org.apache.logging.log4j:log4j-core:2.8.2',
'org.json:json:20171018',
'org.ini4j:ini4j:0.5.4',
'mysql:mysql-connector-java:8.0.18',
'com.google.code.findbugs:annotations:3.0.1',
)
// Test resources
testImplementation(
// External resources
'junit:junit:4.12',
'org.junit.jupiter:junit-jupiter-api:5.5.0',
'org.powermock:powermock-api-mockito:1.6.4',
'org.powermock:powermock-module-junit4:1.6.4',
)
clover 'org.openclover:clover:4.3.1'
}

// Settings for the Clover coverage report -- not a task; See cloverGenerateReport
clover {
enabled = true

    report {
            html = true
            xml  = true
            pdf = false

            // Support capturing test results from JUnix XML report
            testResultsInclude = 'TEST-*.xml'
            testResultsDir = reportDir
    }

}

Stacktrace
What went wrong:
Execution failed for task ':cloverGenerateReport'.

com.atlassian.clover.api.CloverException: java.lang.NullPointerException

  • Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cloverGenerateReport'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    Caused by: : com.atlassian.clover.api.CloverException: java.lang.NullPointerException
    at com.atlassian.clover.ant.tasks.CloverReportTask.cloverExecute(CloverReportTask.java:398)
    at com.atlassian.clover.ant.tasks.AbstractCloverTask.execute(AbstractCloverTask.java:57)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:78)
    at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:103)
    at com.bmuschko.gradle.clover.CloverReportTask.writeReport(CloverReportTask.groovy:182)
    at com.bmuschko.gradle.clover.CloverReportTask.writeReports(CloverReportTask.groovy:154)
    at com.bmuschko.gradle.clover.GenerateCoverageReportTask.generateReport(GenerateCoverageReportTask.groovy:59)
    at com.bmuschko.gradle.clover.GenerateCoverageReportTask.generateCodeCoverage(GenerateCoverageReportTask.groovy:43)
    at com.bmuschko.gradle.clover.CloverReportTask.start(CloverReportTask.groovy:257)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 29 more
    Caused by: com.atlassian.clover.api.CloverException: java.lang.NullPointerException
    at com.atlassian.clover.reporters.html.HtmlReporter.executeImpl(HtmlReporter.java:196)
    at com.atlassian.clover.reporters.CloverReporter.execute(CloverReporter.java:38)
    at com.atlassian.clover.ant.tasks.CloverReportTask.generateReports(CloverReportTask.java:435)
    at com.atlassian.clover.ant.tasks.CloverReportTask.cloverExecute(CloverReportTask.java:395)
    ... 52 more
    Caused by: java.lang.NullPointerException
    at clover.org.jfree.chart.axis.ValueAxis.findMaximumTickLabelWidth(ValueAxis.java:916)
    at clover.org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:828)
    at clover.org.jfree.chart.plot.XYPlot.calculateRangeAxisSpace(XYPlot.java:3077)
    at clover.org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:2988)
    at clover.org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3132)
    at clover.org.jfree.chart.JFreeChart.draw(JFreeChart.java:1229)
    at clover.org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1399)
    at clover.org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:211)
    at clover.org.jfree.chart.ChartUtilities.saveChartAsPNG(ChartUtilities.java:341)
    at com.atlassian.clover.reporters.util.CloverChartFactory.generateHistogramChart(CloverChartFactory.java:156)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeCurrentReport(HtmlReporter.java:266)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeImpl(HtmlReporter.java:188)
    ... 55 more

@Alex-Vol-SV
Copy link
Collaborator

There is nothing I can see from this stack trace within the control of this plugin. The error appears internal to the OpenClover library implementation. I think you need to raise this as an issue with OpenClover instead.

@marek-parfianowicz
Copy link

marek-parfianowicz commented Feb 10, 2020

Caused by: java.lang.NullPointerException at clover.org.jfree.chart.axis.ValueAxis.findMaximumTickLabelWidth(ValueAxis.java:916)

Code:
>>> FontMetrics fm = g2.getFontMetrics(font);

A problem with graphics, maybe? A DISPLAY is missing? A font is missing?

@Alex-Vol-SV
Copy link
Collaborator

There is a very easy fix for this issue. Add the following to your gradle.properties

systemProp.java.awt.headless=true

Neither Gradle tools and plugins nor this plugin really need an actual graphics display to perform their work. I use this in my build and eliminate the problem.

@Alex-Vol-SV
Copy link
Collaborator

Since this is a common kind of failure when advanced options are used I will take the time to add a documentation pointer to this solution.

@DSEyers
Copy link
Author

DSEyers commented Feb 28, 2020 via email

@Alex-Vol-SV
Copy link
Collaborator

Nothing more I can do for you, this failure is inside the shaded library org.jfree.chart within the OpenClover tools. You might want to try also setting GRADLE_OPTS=-Djava.awt.headless=true

@marek-parfianowicz
Copy link

marek-parfianowicz commented Feb 28, 2020 via email

@marek-parfianowicz
Copy link

marek-parfianowicz commented Feb 28, 2020 via email

@Alex-Vol-SV
Copy link
Collaborator

For Gradle you can use --max-workers=1 to avoid running parallel tests that get Clover rendering in trouble.

@Alex-Vol-SV
Copy link
Collaborator

If this is is an option for the Ant tasks I can add it to the Gradle plugin, we are using Ant tasks for integration. Thanks @marek-parfianowicz

@marek-parfianowicz
Copy link

marek-parfianowicz commented Feb 28, 2020 via email

@DSEyers
Copy link
Author

DSEyers commented Mar 9, 2020

None of the solutions worked. Going to file ticker with OpenClover group and thanks for all your help.

@Alex-Vol-SV
Copy link
Collaborator

If I have time this week I will try to expose the maxThreads option for report generation so you can try that approach as well.

@marek-parfianowicz
Copy link

  1. Yes, it would be great to add a maxThreads option, at least we could check if the workaround works.

  2. What Java version do you use to execute Gradle? I'm asking, because Clover was tested up to JDK 9 and probably won't run on newer JDK.

  3. If the NPE is thrown from the columnsTL.get() then resetThreadLocals must have been called (as it sets the field to null, by default it's new ThreadLocal<List<Column>>()). It's being called on cleanup, see https://bitbucket.org/openclover/clover/src/24bfea8880f06e225e95a341813056b664dd3a1f/clover-core/src/main/java/com/atlassian/clover/reporters/html/HtmlReporter.java?at=default#lines-315

Maybe the Timeout of XXX reached during report generation. Please increase this value and try again. was reached? Could you check logs, please?

@Alex-Vol-SV
Copy link
Collaborator

I added the timeout interval and numThreads options in the 2.2.5 version.
It should appear in the plugins portal within 24 hours.

Perhaps either or both of these options will make a difference.

@DSEyers
Copy link
Author

DSEyers commented Mar 10, 2020 via email

@DSEyers
Copy link
Author

DSEyers commented Mar 12, 2020

I tried a few things, but not able to get the updated plugin seen.

Tried:

And in a lank new folder creating and running build.grade with full contents of:

buildscript {
repositories {
jcenter()
}

    dependencies {
        classpath 'com.bmuschko:gradle-clover-plugin:2.2.5'
    }
}

Also just incrementing version in the project and running Gradle. We using Gradle 4.4.1 and plugin syntax used is:

plugins {
id 'com.bmuschko.clover' version '2.2.5'
}

repositories {
mavenCentral()
jcenter()
}

@Alex-Vol-SV
Copy link
Collaborator

There was an issue with the Gradle plugin portal. The Gradle team is fixing it. The release will be available from there soon I hope.

@Alex-Vol-SV
Copy link
Collaborator

If you are trying it locally you need to add mavenLocal() to the repositories. You only have mavenCentral() and jcenter()

@Alex-Vol-SV
Copy link
Collaborator

When you use the plugins closure DSL to load it you also need to add mavenLocal() to the settings.gradle under pluginManagement closure.

@Alex-Vol-SV
Copy link
Collaborator

Alex-Vol-SV commented Mar 13, 2020

Plugin 2.2.5 is now available at the Gradle portal. Try it out with the suggestions @marek-parfianowicz made.

This is how you configure them

clover {
    report {
        numThreads = 1
        timeout = '30 seconds'
    }
}

Default timeout is no-timeout so it is unlikely you reached a timeout.
numThreads = 0 according to OpenClover docs disables multithreading, I suppose it is probably better in some ways than 1 thread.

@DSEyers
Copy link
Author

DSEyers commented Mar 13, 2020 via email

@Alex-Vol-SV
Copy link
Collaborator

We use the reckon plugin to discover the version assuming you are cloning the git repository which brings in the release tags. You did not clone the repository which means you did not get the git tags therefore your version was 0.0.1.

Sorry this did not make your problem better. This is unique and completely within the OpenClover library so I cannot tell why you get this. Did you actually change the clover configuration as suggested above? That is how it would work, the new version would not be the fix, the configuration change would be the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants