| Summary: | TextUtils.shortenText() throws PatternSyntaxException | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Grant Gayed <grant_gayed> | ||||
| Component: | Debug | Assignee: | Grant Gayed <grant_gayed> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Michael Rennie <Michael_Rennie> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | thatnitind | ||||
| Version: | 3.4 | ||||||
| Target Milestone: | 3.4 M2 | ||||||
| Hardware: | PC | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 357399 | ||||||
| Attachments: |
|
||||||
(The URL that hit this problem was "http://feed.theplatform.com/f/h9dtGB/r3VD0FujBumK?form=json&fields=title,content,description,defaultThumbnailUrl,pubDate,:liveOndemand,:genre&releaseFields=id,approved&byApproved=true&byCategoryIds=1221258968&range=1-6&callback=CBC.APP.playlist745576.processFeedData") Comment on attachment 202920 [details]
patch
This patch uses String API that's too new. Here's a better implementation of the method:
public static String shortenText(String string, int threshold) {
int length = string.length();
if (length > threshold) {
int chomp = length - threshold + 3;
int begin = Math.round(threshold/2)-1;
StringBuffer buff = new StringBuffer();
buff.append(string.substring(0, begin)).append("...").append(string.substring(begin+chomp)); //$NON-NLS-1$
return buff.toString();
}
return string;
}
Comment 2 implementation is tested and committed to the HEAD and R3_2_maintenance streams > 20110908. R3_3_maintenance stream is still TODO, once the rest of the Crossfire stuff has arrived there. (In reply to comment #3) > Comment 2 implementation is tested and committed to the HEAD and > R3_2_maintenance streams > 20110908. R3_3_maintenance stream is still TODO, > once the rest of the Crossfire stuff has arrived there. I am going to mark this as fixed, R3_3_maintenance will just get all of the fixes from HEAD when the back-port is done - so we don't need to keep this bug open for that. I will clone this bug and target it for 3.3.2+ fixed. |
Created attachment 202920 [details] patch This method is using String.replaceAll() instead of String.replace(), and as a result is failing because replaceAll() expects its argument to be a regex. Fix is committed to HEAD. Creating this report as a reminder to make this change in the 3_2_ and 3_3_maintenance streams once the initial backport of crossfire to these streams is done.