Skip to content

ClassCastException in ErrorHandler if agent sends a non-numeric lineNumber #644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
javabrett opened this issue Jun 10, 2015 · 1 comment
Closed

Comments

@javabrett
Copy link
Contributor

Selenium 2.46.0, Firefox 38.0.5.

Saw this exception during a test:

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
    at org.openqa.selenium.remote.ErrorHandler$FrameInfoToStackFrame.apply(ErrorHandler.java:297)
    at org.openqa.selenium.remote.ErrorHandler$FrameInfoToStackFrame.apply(ErrorHandler.java:1)
    at com.google.common.collect.Iterators$8.next(Iterators.java:782)
    at com.google.common.collect.Iterators$7.computeNext(Iterators.java:644)
    at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141)
    at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136)
    at com.google.common.collect.Lists.newArrayList(Lists.java:138)
    at com.google.common.collect.Iterables.toCollection(Iterables.java:312)
    at com.google.common.collect.Iterables.toArray(Iterables.java:290)
    at org.openqa.selenium.remote.ErrorHandler.rebuildServerError(ErrorHandler.java:270)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:118)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
    at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:172)
    at org.openqa.selenium.remote.RemoteWebElement.findElementById(RemoteWebElement.java:205)
    at org.openqa.selenium.By$ById.findElement(By.java:215)
    at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:168)

From looking at some of the agents' source, it seems possible that sometimes a stack frame might contain lineNumber = "" (empty string) or even lineNumber = "Not available", which could explain the above CCE.

ErrorHandler$FrameInfoToStackFrame.apply should be more defensive when pulling LINE_NUMBER from the map. It also currently bails-out with no info if the line number is absent, whereas it seems reasonable that it could create a stack frame with line number = -1, negative (but not -2 == in-native) being conventional for unknown per java.lang.StackTraceElement.

javabrett added a commit to javabrett/selenium that referenced this issue Jun 10, 2015
…eNumber, and also attempts to safely parse a non-Number Object if it receives a non-Number.

If absent or non-numeric it now continues to build the StackTraceElement (instead of aborting that frame) and uses the conventional -1 for lineNumber.

Signed-off-by: Brett Randall <[email protected]>
barancev pushed a commit that referenced this issue Jun 18, 2015
…nd also attempts to safely parse a non-Number Object if it receives a non-Number.

If absent or non-numeric it now continues to build the StackTraceElement (instead of aborting that frame) and uses the conventional -1 for lineNumber.

Signed-off-by: Alexei Barantsev <[email protected]>
@barancev
Copy link
Member

Fixed by bdf4170

@lock lock bot locked and limited conversation to collaborators Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants