Description
When running openHAB integration tests with bnd-testing-maven-plugin 7.3.0, a temporary launch*.properties file can be left behind when the test fails while preparing the OSGi runtime, for example because the required bundles cannot be resolved.
We ran into this in openHAB here:
https://github.com/openhab/openhab-addons/actions/runs/31677377310/job/94374812202
openHAB currently uses bnd 7.3.0:
https://github.com/openhab/openhab-addons/blob/main/pom.xml
After the failed integration test, a generated launch*.properties file remains in the test module instead of being cleaned up. Since it is a temporary launcher artifact, it would be preferable for it to be removed on failure as well as on a normal test run.
Expected behavior
Temporary launcher files are cleaned up even if test preparation or bundle resolution fails before the OSGi framework is launched.
Actual behavior
If preparation fails, the temporary launch*.properties file remains on disk.
Possible cause
ProjectLauncherImpl creates the temporary launch properties file in its constructor and removes it from cleanup().
The testing path appears to have failure paths before the cleanup protected by ProjectLauncher.launch() is reached. In particular, ProjectTesterImpl.test() calls prepare() before calling getProjectLauncher().launch(), and ProjectLauncherImpl.launch() also calls prepare() before delegating to super.launch().
So if prepare() throws, for example due to a bundle resolution/preparation problem, cleanup() may never be called.
Looking at current master, this control flow appears to still be present, so this may not be specific to bnd 7.3.0.
Related issue
This looks similar to #326, where temporary launch*.properties files were left behind. That issue was fixed by calling cleanup() for the export path, so this may be an equivalent cleanup gap in the testing/preparation path.
Description
When running openHAB integration tests with
bnd-testing-maven-plugin7.3.0, a temporarylaunch*.propertiesfile can be left behind when the test fails while preparing the OSGi runtime, for example because the required bundles cannot be resolved.We ran into this in openHAB here:
https://github.com/openhab/openhab-addons/actions/runs/31677377310/job/94374812202
openHAB currently uses bnd 7.3.0:
https://github.com/openhab/openhab-addons/blob/main/pom.xml
After the failed integration test, a generated
launch*.propertiesfile remains in the test module instead of being cleaned up. Since it is a temporary launcher artifact, it would be preferable for it to be removed on failure as well as on a normal test run.Expected behavior
Temporary launcher files are cleaned up even if test preparation or bundle resolution fails before the OSGi framework is launched.
Actual behavior
If preparation fails, the temporary
launch*.propertiesfile remains on disk.Possible cause
ProjectLauncherImplcreates the temporary launch properties file in its constructor and removes it fromcleanup().The testing path appears to have failure paths before the cleanup protected by
ProjectLauncher.launch()is reached. In particular,ProjectTesterImpl.test()callsprepare()before callinggetProjectLauncher().launch(), andProjectLauncherImpl.launch()also callsprepare()before delegating tosuper.launch().So if
prepare()throws, for example due to a bundle resolution/preparation problem,cleanup()may never be called.Looking at current
master, this control flow appears to still be present, so this may not be specific to bnd 7.3.0.Related issue
This looks similar to #326, where temporary
launch*.propertiesfiles were left behind. That issue was fixed by callingcleanup()for the export path, so this may be an equivalent cleanup gap in the testing/preparation path.