Skip to content

NPE from RunnerTestDescriptor.lambda$logIncompleteFiltering$2 #2601

@jglick

Description

@jglick

Given pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>plugin</artifactId>
        <version>4.18</version>
        <relativePath />
    </parent>
    <artifactId>demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>hpi</packaging>
    <properties>
        <jenkins.version>2.277.3</jenkins.version>
        <java.level>8</java.level>
        <junit5.version>5.7.1</junit5.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>${junit5.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                        <version>${junit5.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>
</project>

and src/main/resources/index.jelly

<?xml version="1.0" encoding="UTF-8"?>
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
    XXX
</j:jelly>

then

mvn -f /tmp/junit-npe clean verify -e

passes

[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.021 s - in InjectedTest

yet

mvn -f /tmp/junit-npe clean verify -e -Dtest=InjectedTest

fails with

Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test failed: java.lang.NullPointerException
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at …
Caused by: org.apache.maven.surefire.util.SurefireReflectionException: java.lang.NullPointerException
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray (ReflectionUtils.java:177)
    at …
Caused by: java.lang.NullPointerException
    at org.junit.vintage.engine.descriptor.RunnerTestDescriptor.lambda$logIncompleteFiltering$2 (RunnerTestDescriptor.java:118)
    at org.junit.platform.commons.logging.LoggerFactory$DelegatingLogger.nullSafeGet (LoggerFactory.java:182)
    at org.junit.platform.commons.logging.LoggerFactory$DelegatingLogger.log (LoggerFactory.java:146)
    at org.junit.platform.commons.logging.LoggerFactory$DelegatingLogger.warn (LoggerFactory.java:95)
    at org.junit.vintage.engine.descriptor.RunnerTestDescriptor.logIncompleteFiltering (RunnerTestDescriptor.java:117)
    at org.junit.vintage.engine.descriptor.RunnerTestDescriptor.prune (RunnerTestDescriptor.java:111)
    at org.junit.platform.engine.TestDescriptor.accept (TestDescriptor.java:249)
    at org.junit.platform.engine.TestDescriptor.lambda$accept$0 (TestDescriptor.java:251)
    at java.lang.Iterable.forEach (Iterable.java:75)
    at org.junit.platform.engine.TestDescriptor.accept (TestDescriptor.java:251)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.lambda$acceptInAllTestEngines$8 (EngineDiscoveryOrchestrator.java:167)
    at java.util.LinkedHashMap$LinkedValues.forEach (LinkedHashMap.java:608)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.acceptInAllTestEngines (EngineDiscoveryOrchestrator.java:167)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.prune (EngineDiscoveryOrchestrator.java:158)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover (EngineDiscoveryOrchestrator.java:93)
    at org.junit.platform.launcher.core.DefaultLauncher.discover (DefaultLauncher.java:92)
    at org.junit.platform.launcher.core.DefaultLauncher.discover (DefaultLauncher.java:67)
    at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept (TestPlanScannerFilter.java:56)
    at org.apache.maven.surefire.util.DefaultScanResult.applyFilter (DefaultScanResult.java:102)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath (JUnitPlatformProvider.java:146)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.getSuites (JUnitPlatformProvider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray (ReflectionUtils.java:169)
    at …

Seems to be some sort of missing null check in https://github.com/junit-team/junit5/blob/ddaec1bb07b6a3ed3afd318bc9412d9e848b499f/junit-vintage-engine/src/main/java/org/junit/vintage/engine/descriptor/RunnerTestDescriptor.java#L117-L119

The situation here is admittedly unusual: a JUnit 3 target/generated-test-sources/injected/InjectedTest.java created by a custom Maven plugin. Normally works fine in Surefire with JUnit 4 in the classpath, but seems to confuse the JUnit 5 vintage engine.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions