TSK-115 JAASRunner throws ClassCastException if tests fail

This commit is contained in:
BerndBreier 2018-01-05 14:10:53 +01:00 committed by Holger Hagen
parent a6f95fcd55
commit 69784458af
1 changed files with 13 additions and 6 deletions

View File

@ -57,17 +57,24 @@ public class JAASRunner extends BlockJUnit4ClassRunner {
try { try {
base.evaluate(); base.evaluate();
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof Exception) {
throw (Exception) e;
} else {
throw new Exception(e); throw new Exception(e);
} }
}
return null; return null;
} }
}); });
} catch (PrivilegedActionException e) { } catch (PrivilegedActionException e) {
throw (Exception) e.getCause(); Throwable cause = e.getCause();
Throwable nestedCause = null;
if (cause != null) {
nestedCause = cause.getCause();
}
if (nestedCause != null) {
throw nestedCause;
} else if (cause != null) {
throw cause;
} else {
throw e;
}
} }
} }
}; };