提交 244c0bd0 authored 作者: Andrei Tokar's avatar Andrei Tokar

TestCrashAPI: filter NPE

上级 d12f1114
...@@ -383,6 +383,7 @@ public class TestCrashAPI extends TestDb implements Runnable { ...@@ -383,6 +383,7 @@ public class TestCrashAPI extends TestDb implements Runnable {
boolean isDefault = boolean isDefault =
(m.getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC (m.getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC
&& m.getDeclaringClass().isInterface(); && m.getDeclaringClass().isInterface();
boolean allowNPE = isDefault || o instanceof Blob && "setBytes".equals(m.getName());
Class<?>[] paramClasses = m.getParameterTypes(); Class<?>[] paramClasses = m.getParameterTypes();
Object[] params = new Object[paramClasses.length]; Object[] params = new Object[paramClasses.length];
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
...@@ -398,7 +399,7 @@ public class TestCrashAPI extends TestDb implements Runnable { ...@@ -398,7 +399,7 @@ public class TestCrashAPI extends TestDb implements Runnable {
TestBase.logError("error", e); TestBase.logError("error", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Throwable t = e.getTargetException(); Throwable t = e.getTargetException();
printIfBad(seed, id, objectId, t, isDefault); printIfBad(seed, id, objectId, t, allowNPE);
} }
if (result == null) { if (result == null) {
return null; return null;
...@@ -414,7 +415,7 @@ public class TestCrashAPI extends TestDb implements Runnable { ...@@ -414,7 +415,7 @@ public class TestCrashAPI extends TestDb implements Runnable {
printIfBad(seed, id, objectId, t, false); printIfBad(seed, id, objectId, t, false);
} }
private void printIfBad(int seed, int id, int objectId, Throwable t, boolean isDefault) { private void printIfBad(int seed, int id, int objectId, Throwable t, boolean allowNPE) {
if (t instanceof BatchUpdateException) { if (t instanceof BatchUpdateException) {
// do nothing // do nothing
} else if (t.getClass().getName().contains("SQLClientInfoException")) { } else if (t.getClass().getName().contains("SQLClientInfoException")) {
...@@ -438,8 +439,8 @@ public class TestCrashAPI extends TestDb implements Runnable { ...@@ -438,8 +439,8 @@ public class TestCrashAPI extends TestDb implements Runnable {
// General error [HY000] // General error [HY000]
printError(seed, id, s); printError(seed, id, s);
} }
} else if (isDefault && t instanceof NullPointerException) { } else if (allowNPE && t instanceof NullPointerException) {
// do nothing, default methods may throw this exception // do nothing, this methods may throw this exception
} else { } else {
printError(seed, id, t); printError(seed, id, t);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论