Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344532 - [ZoomManager] StringIndexOutOfBoundsException when zoomString is empty
Summary: [ZoomManager] StringIndexOutOfBoundsException when zoomString is empty
Status: RESOLVED WORKSFORME
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: 3.6.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-03 03:57 EDT by Karsten Thoms CLA
Modified: 2014-08-10 17:16 EDT (History)
1 user (show)

See Also:


Attachments
Screenshot: Debugger (539.11 KB, image/png)
2011-05-03 03:57 EDT, Karsten Thoms CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Thoms CLA 2011-05-03 03:57:23 EDT
Created attachment 194553 [details]
Screenshot: Debugger

I just catched StringIndexOutOfBoundException in ZoomManager#setZoomAsText(). The passed in zoomString is empty, which causes a StringIndexOutOfBoundsException in this line:
   if (zoomString.charAt(zoomString.length() - 1) == '%')

It might be already an error that an empty string comes in, but here I had no chance influence this. It happened when I initialize an UML class diagram with Topcased.

However, the code in ZoomManager should handle this situation more gracefully, e.g. returning fast when the argument is null or empty.
Comment 1 Alexander Nyßen CLA 2014-08-10 17:16:46 EDT
It seems the code was designed this way. All checks related to the validity of the zoom string are handled by having the parsing surrounded with a try/catch block that catches any Exception. The StringIndexOutOfBoundsException is thus never exposed to a client, instead a Display#beep() is issued in such I case (happens within the catch block). As such, resolving this as WORKSFORME.