| Summary: | [BrowserFunction] fails if empty array is returned | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Philipp Leusmann <leusmann> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | ||
| Version: | 1.3 | ||
| Target Milestone: | 1.4 M1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Fixed in CVS HEAD. Are you sure that SWT supports Collection in the result object? If yes, please open a separate bug with a snippet to reproduce it. Ivan, I don't know if SWT supports collections and to not really have an opportunity to look it up. I just thought it would be a natural extension. I've just checked it in SWT (Snippet307.java) and exception is thrown in case of Collection - "Return value not valid". |
Build Identifier: When a BrowserFunction returns an empty array, org.eclipse.swt.internal.browser.browserkit.BrowserLCA.toJson(Object, boolean) encodes it as "][". as a patch, the concerned if-block in said method could be: else if (object.getClass().isArray()) { Object[] array = (Object[]) object; result.append("["); for (int i = 0; i < array.length; i++) { result.append(toJson(array[i], false)); } if (',' == result.charAt(result.length() - 1)) { // insert ']' before last ',' result.insert(result.length() - 1, "]"); } else { // special handling for empty array result.append("],"); } } Also there are two related topics: 1) The method does not handle collections. An adequate addition would be else if (object instanceof Collection) { result.append(toJson(((Collection) object).toArray(), false)); } 2) What is the deleteLastChar-argument good for? Wouldn't it be sufficient to check, if the last character of the returned string is ',' and remove it, if needed? Reproducible: Always