Skip to content

[πŸ› Bug]: java.lang.ArrayIndexOutOfBoundsException: Index N out of bounds for length NΒ #14414

@jherncandle

Description

@jherncandle

What happened?

Starting my TestNG automated tests and setting capabilities for the driver I am using and every now and then I get this error in the selenium stack:

java.lang.ArrayIndexOutOfBoundsException: Index 11 out of bounds for length 11
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.accept(SortedOps.java:369)
at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet.lambda$entryConsumer$0(Collections.java:1576)
at java.base/java.util.TreeMap$EntrySpliterator.forEachRemaining(TreeMap.java:2962)
at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntrySetSpliterator.forEachRemaining(Collections.java:1601)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at org.openqa.selenium.SharedCapabilitiesMethods.abbreviate(SharedCapabilitiesMethods.java:117)
at org.openqa.selenium.SharedCapabilitiesMethods.toString(SharedCapabilitiesMethods.java:84)
at org.openqa.selenium.MutableCapabilities.toString(MutableCapabilities.java:138)
at java.base/java.lang.String.valueOf(String.java:2951)
at org.openqa.selenium.SharedCapabilitiesMethods.abbreviate(SharedCapabilitiesMethods.java:120)
at org.openqa.selenium.SharedCapabilitiesMethods.lambda$abbreviate$4(SharedCapabilitiesMethods.java:116)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at org.openqa.selenium.SharedCapabilitiesMethods.abbreviate(SharedCapabilitiesMethods.java:117)
at org.openqa.selenium.SharedCapabilitiesMethods.toString(SharedCapabilitiesMethods.java:84)
at org.openqa.selenium.MutableCapabilities.toString(MutableCapabilities.java:138)

How can we reproduce the issue?

Not sure how since I observe the problem occasionally, not all the time, but it stems from a
AbstractDriverOptions.toString() call
         Log.trace("new remote webdriver: " + driverOptions.toString());

where driverOptions is:
        AbstractDriverOptions driverOptions = Browser.getDriverOptions(driverType);
and Browser.getDriverOptions is:
    public static AbstractDriverOptions getDriverOptions(Driver.DriverType type) {
        switch (type) {
            case CHROME:
                return (new Chrome()).getChromeOptions();
            case EDGE:
                return (new Edge()).getEdgeOptions();
            case FIREFOX:
                return (new Firefox()).getFirefoxOptions();
            case IE:
                return (new IE()).getInternetExplorerOptions();
            case SAFARI:
                return (new Safari()).getSafariOptions();
            default:
                throw new IllegalArgumentException("invalid driver type:" + type);
        }
    }

Relevant log output

java.lang.ArrayIndexOutOfBoundsException: Index 11 out of bounds for length 11
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.accept(SortedOps.java:369)
	at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet.lambda$entryConsumer$0(Collections.java:1576)
	at java.base/java.util.TreeMap$EntrySpliterator.forEachRemaining(TreeMap.java:2962)
	at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntrySetSpliterator.forEachRemaining(Collections.java:1601)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.openqa.selenium.SharedCapabilitiesMethods.abbreviate(SharedCapabilitiesMethods.java:117)
	at org.openqa.selenium.SharedCapabilitiesMethods.toString(SharedCapabilitiesMethods.java:84)
	at org.openqa.selenium.MutableCapabilities.toString(MutableCapabilities.java:138)
	at java.base/java.lang.String.valueOf(String.java:2951)
	at org.openqa.selenium.SharedCapabilitiesMethods.abbreviate(SharedCapabilitiesMethods.java:120)
	at org.openqa.selenium.SharedCapabilitiesMethods.lambda$abbreviate$4(SharedCapabilitiesMethods.java:116)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.openqa.selenium.SharedCapabilitiesMethods.abbreviate(SharedCapabilitiesMethods.java:117)
	at org.openqa.selenium.SharedCapabilitiesMethods.toString(SharedCapabilitiesMethods.java:84)
	at org.openqa.selenium.MutableCapabilities.toString(MutableCapabilities.java:138)

Operating System

We see this on Windows11, MacOs Ventura(13.5)

Selenium version

Java 11 with Selenium 4.9.1

What are the browser(s) and version(s) where you see this issue?

Chrome, Edge, Firefox and Safari

What are the browser driver(s) and version(s) where you see this issue?

geckodriverVersion: 0.35.0, Safari browserVersion: 17.1, chromedriverVersion: 127.0.6533.72, MicrosoftEdge, browserVersion: 127.0.2651.74

Are you using Selenium Grid?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-defectSomething is not working as intendedJ-issue-templateApplied to issues not following the template, or missing information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions