Issue Details (XML | Word | Printable)

Key: SRC-707
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Philippe Hanrigou
Reporter: Vojtech
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Selenium Remote Control

Selenium#retrieveLastRemoteControlLogs() fails on StringIndexOutOfBoundsException

Created: 15/Jul/09 07:39 AM   Updated: 15/Jul/09 04:45 PM   Resolved: 15/Jul/09 04:45 PM
Component/s: Server
Affects Version/s: 1.0.1
Fix Version/s: 1.0.2

File Attachments: 1. File SeleniumDriverResourceHandler-corrected.diff (0.8 kB) 15/Jul/09 07:52 AM - Vojtech
2. File SeleniumDriverResourceHandler.diff (34 kB) 15/Jul/09 07:39 AM - Vojtech

Environment: Win XP, jdk1.5.0_15, all browsers, Selenium server / client driver 1.0.1


 Description  « Hide

In my tests, which use Selenium client driver API, calling Selenium#retrieveLastRemoteControlLogs() results in "com.thoughtworks.selenium.SeleniumException: Internal Server Error".

This is because Selenium server (Jetty) returns HTTP response code 500 after invoking HttpCommandProcessor#getCommandResponseAsString("cmd=retrieveLastRemoteControlLogs"). In fact, each server response with code other than 200 (OK) raises a SeleniumException with non-descriptive generic message built from the response code, for example "Internal Server Error". I would personally prefer something more sensible, e.g. "error while processing command ABC, server returned code XYZ".

Anyway, this means that the error occurs on Selenium server (servlet bound to "/selenium-server/driver/" throws an exception). Root cause for this exception is in SeleniumDriverResourceHandler#doCommand(...) method, line 558:

...
} else if (RetrieveLastRemoteControlLogsCommand.ID.equals(cmd)) { /* Trim logs to avoid Larsen effect (see remote control stability tests) */ LOGGER.info("Got result:" + results.substring(0, 30) + "... on session " + sessionId); }
...

If result.length() >= 30, this will throw "java.lang.StringIndexOutOfBoundsException: String index out of range: 30".

Proposed fix: don't call results.substring(0, 30) unless you know its length is less than 30 characters.



Vojtech added a comment - 15/Jul/09 07:52 AM

I messed up the original diff please find the correct diff attached: SeleniumDriverResourceHandler-corrected.diff


Vojtech made changes - 15/Jul/09 07:52 AM
Field Original Value New Value
Attachment SeleniumDriverResourceHandler-corrected.diff [ 11974 ]
Philippe Hanrigou made changes - 15/Jul/09 03:39 PM
Assignee Philippe Hanrigou [ ph7 ]
Philippe Hanrigou added a comment - 15/Jul/09 03:39 PM

This is a bug indeed!


Philippe Hanrigou made changes - 15/Jul/09 04:09 PM
Status Open [ 1 ] In Progress [ 3 ]
Philippe Hanrigou added a comment - 15/Jul/09 04:45 PM

Fixed in rev 2704


Philippe Hanrigou made changes - 15/Jul/09 04:45 PM
Resolution Fixed [ 1 ]
Fix Version/s 1.0.2 [ 10702 ]
Status In Progress [ 3 ] Resolved [ 5 ]