ops4j / org.ops4j.pax.exam2

Pax Exam is a testing framework for OSGi
https://ops4j1.jira.com/wiki/spaces/PAXEXAM4/
Apache License 2.0
84 stars 100 forks source link

Suite may be empty and will produce java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 #1116

Open juherr opened 2 months ago

juherr commented 2 months ago

The current implementation doesn't manage the case where the suite is empty:

Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

        at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
        at java.base/java.util.Objects.checkIndex(Objects.java:361)
        at java.base/java.util.ArrayList.get(ArrayList.java:427)
        at org.ops4j.pax.exam.testng.listener.PaxExam.stageReactor(PaxExam.java:224)
        at org.ops4j.pax.exam.testng.listener.PaxExam.onStart(PaxExam.java:186)
        at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:242)
        at org.testng.SuiteRunner.run(SuiteRunner.java:310)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/drivers/pax-exam-testng/src/main/java/org/ops4j/pax/exam/testng/driver/DriverListener.java#L153-L154

juherr commented 2 months ago

@krmahadevan fyi if you want to propose a fix

krmahadevan commented 2 months ago

@juherr - I would first want to wait for my existing PR to be merged before I spend time raising new PRs.

I am still waiting for feedback on https://github.com/ops4j/org.ops4j.pax.exam2/pull/1112

oliverlietz commented 1 month ago

The "current" (abandoned) version 5 wasn't touched for 7 years. See also the refactoring mentioned in PAXEXAM-772. Do you have capacity to backport the approach to 4.x?