Skip to content

ClasspathScanner#determineSubpackageName sometimes resolves to wrong subpackageName starting with '...' #2612

Closed
@hosuaby

Description

@hosuaby

This bug was introduced in JUnit 5.7.1. 5.7.0 have no such a problem.

Example:

Path baseDir = "/com/fasterxml/jackson/core/base/";
Path classFile = "/com/fasterxml/jackson/core/base/ParserMinimalBase.class";
String subpackageName = determineSubpackageName(baseDir, classFile);
// subpackageName now equals "...base"

The bug is probaby due to commit #2531 (Fix package path computation in ClasspathScanner )

I got this bug because I use ReflectionSupport#findAllClassesInPackage inside my JUnit Jupiter plugin.

Steps to reproduce

To reproduce the bug is quite a trick. So project https://github.com/jlrosa/testwithresources was created. Here the steps to do

  1. Clone the project, execute mvn clean install, and open the project in IDE.
  2. Setup a breakpoint in ClasspathScanner#processClassFileSafely line 131.
  3. Run the test InjectResourcesTest in debug mode.
  4. Java debugger will stop. Check the value of the variable fullyQualifiedClassName. It will be something like: "com.adelean.inject.resources.junit.jupiter....jupiter.WithJacksonMapper"

Context

  • Used versions (Jupiter/Vintage/Platform): JUnit 5.7.1
  • Build Tool/IDE: Intellij

Deliverables

  • ...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions