October 2003
Intermediate to advanced
416 pages
8h 1m
English
When we notify an extension, we don't have any control over what happens next. The contract we would like to maintain is that we notify all extenders regardless of failures. Consider a malicious listener:
public static class BadListener implements ITestRunListener {
...
public void testsStarted(int testCount) {
throw new NullPointerException();
}
}
If we wrote a simple loop to notify all extensions, when we got to our BadListener an exception would be thrown, terminating the loop prematurely. So, here's another Eclipse rule:
GOOD FENCES RULE. When passing control outside your code, protect yourself.
Applying this rule, when we notify our extensions, we need to do so safely. Because this is a common idiom in Eclipse, ...
Read now
Unlock full access