pmd: fix #1087 PreserveStackTrace (still) ignores initCause()

one more test, extended documentation example
This commit is contained in:
Andreas Dangel 2013-04-25 18:35:06 +02:00
parent b77de63950
commit 2d655f4684
2 changed files with 14 additions and 3 deletions

View File

@ -1354,7 +1354,12 @@ public class Foo {
try{
Integer.parseInt("a");
} catch (Exception e) {
throw new Exception(e);
throw new Exception(e); // first possibility to create exception chain
}
try {
Integer.parseInt("a");
} catch (Exception e) {
throw (IllegalStateException)new IllegalStateException().initCause(e); // second possibility to create exception chain.
}
}
void bad() {

View File

@ -462,6 +462,12 @@ public class Test {
noSuchElementException.initCause(arrayIndexOutOfBoundsException);
throw noSuchElementException;
}
try {
// do something
} catch (ArrayOutOfBoundsException e) {
throw (IllegalStateException)new IllegalStateException().initCause(e);
}
}
}
]]></code>