Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344532

Summary: [ZoomManager] StringIndexOutOfBoundsException when zoomString is empty
Product: [Tools] GEF Reporter: Karsten Thoms <karsten.thoms>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 3.6.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Screenshot: Debugger none

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.