| Summary: | NullPointerException in AbstractEditPolicy#toString() when called w/o host set | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Jens Von Pilgrim <developer> |
| Component: | GEF-Legacy GEF (MVC) | Assignee: | Anthony Hunter <ahunter.eclipse> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ahunter.eclipse |
| Version: | 3.2.1 | ||
| Target Milestone: | 3.5.0 (Galileo) M5 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Good catch and you are right. Fixed in HEAD as you have suggested. |
The toString() method in AbstractEditPolicy causes a NullPointerException when it is called without a host set: public String toString() { String c = getClass().getName(); c = c.substring(c.lastIndexOf('.') + 1); return getHost().toString() + "." + c;//$NON-NLS-1$ <------- exception } IMHO toString() methods, primarily used for logging and debugging, should be more robust, i.e. they should never throw an exception, especially if it is so easy to avoid. Suggestion: public String toString() { String c = getClass().getName(); c = c.substring(c.lastIndexOf('.') + 1); if (getHost()!=null) return getHost().toString() + "." + c;//$NON-NLS-1$ else return c + " (no host set yet)"; }