Skip to content

Browser#pause errors due to int overflow #605

Description

@dforegger

Overview

When calling Browser.pause() it always errors immediately with geb.waiting.WaitTimeoutException: condition did not pass in 2147483647 seconds (failed with exception).

Diagnosis

I suspect this was broken by 19f9edc11a9a33bcb6f887e555db4eec59d84051 when the double Wait#toMilliseconds(Number) was converted to return an int. The pause code calls waitFor with Integer.MAX_VALUE, so the conversion to milliseconds overflows.

Suggested Fix

Option 1

Update toMilliseconds to return a long. This is more robust and safer, but more invasive.

Option 2

Update pause to use a value less than the MAX_VALUE / 1000.

Additional Info

Testing

It looks like the test coverage for the pause method - covered in PauseSpec.groovy - does not catch the error because the pause method is called in a separate thread

Stacktrace

Below is my full stacktrace (redacted company info, sorry):

    geb.waiting.WaitTimeoutException: condition did not pass in 2147483647 seconds (failed with exception)
        at geb.waiting.Wait.waitFor(Wait.groovy:124)
        at geb.waiting.DefaultWaitingSupport.doWaitFor(DefaultWaitingSupport.groovy:50)
        at geb.waiting.DefaultWaitingSupport.waitFor(DefaultWaitingSupport.groovy:41)
        at geb.Page.waitFor(Page.groovy:115)
        at geb.Browser.methodMissing(Browser.groovy:250)
        at geb.Browser.pause(Browser.groovy:922)
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:60)
       <at spec method call>

        Caused by:
        Assertion failed: 

        js.'geb.unpause'
        |  |
        |  false
        geb.js.JavascriptInterface@5ef87d55
            at geb.Browser.pause_closure5(Browser.groovy:923)
            at geb.Browser.pause_closure5(Browser.groovy)
            at geb.waiting.Wait.waitFor(Wait.groovy:103)
            ... 7 more

Versions

Geb: v3.1
Gradle 4.7
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_144 (Azul Systems, Inc. 25.144-b01)
OS: Mac OS X 10.15.1 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions