Unverified 提交 79f5d819 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1591 from igor-suhorukov/master

Use multi-catch java 7 language construction to simplify code
......@@ -2030,11 +2030,9 @@ public class Function extends Expression implements FunctionCall {
return ValueString.get(isInPostgreSqlMode && (regexpMode == null || regexpMode.indexOf('g') < 0) ?
matcher.replaceFirst(replacement) : matcher.replaceAll(replacement),
mode.treatEmptyStringsAsNull);
} catch (StringIndexOutOfBoundsException e) {
throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, replacement);
} catch (PatternSyntaxException e) {
throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, regexp);
} catch (IllegalArgumentException e) {
} catch (StringIndexOutOfBoundsException | IllegalArgumentException e) {
throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, replacement);
}
}
......
......@@ -88,9 +88,7 @@ public class DbException extends RuntimeException {
}
}
}
} catch (OutOfMemoryError e) {
DbException.traceThrowable(e);
} catch (IOException e) {
} catch (OutOfMemoryError | IOException e) {
DbException.traceThrowable(e);
}
}
......
......@@ -63,12 +63,11 @@ public class WebServlet extends HttpServlet {
try {
InetAddress address = InetAddress.getByName(addr);
return address.isLoopbackAddress();
} catch (UnknownHostException e) {
return false;
} catch (NoClassDefFoundError e) {
} catch (UnknownHostException | NoClassDefFoundError e) {
// Google App Engine does not allow java.net.InetAddress
return false;
}
}
private String getAllowedFile(HttpServletRequest req, String requestedFile) {
......
......@@ -486,11 +486,7 @@ public class FileLock implements Runnable {
save();
}
Thread.sleep(sleep);
} catch (OutOfMemoryError e) {
// ignore
} catch (InterruptedException e) {
// ignore
} catch (NullPointerException e) {
} catch (OutOfMemoryError | NullPointerException | InterruptedException e) {
// ignore
} catch (Exception e) {
trace.debug(e, "watchdog");
......
......@@ -170,11 +170,7 @@ class FileNioMapped extends FileBase {
dst.position(dst.position() + len);
pos += len;
return len;
} catch (IllegalArgumentException e) {
EOFException e2 = new EOFException("EOF");
e2.initCause(e);
throw e2;
} catch (BufferUnderflowException e) {
} catch (IllegalArgumentException | BufferUnderflowException e) {
EOFException e2 = new EOFException("EOF");
e2.initCause(e);
throw e2;
......
......@@ -77,10 +77,7 @@ public class TestFullText extends TestDb {
testPerformance(true);
testReopen(true);
testDropIndex(true);
} catch (ClassNotFoundException e) {
println("Class not found, not tested: " + LUCENE_FULLTEXT_CLASS_NAME);
// ok
} catch (NoClassDefFoundError e) {
} catch (ClassNotFoundException | NoClassDefFoundError e) {
println("Class not found, not tested: " + LUCENE_FULLTEXT_CLASS_NAME);
// ok
}
......
......@@ -51,9 +51,7 @@ public class TestRandomMapOps extends TestBase {
try {
testOps(fileName, size, seed);
continue;
} catch (Exception e) {
ex = e;
} catch (AssertionError e) {
} catch (Exception | AssertionError e) {
ex = e;
}
if (op < best) {
......
......@@ -393,9 +393,7 @@ public class TestCrashAPI extends TestDb implements Runnable {
try {
callCount++;
result = m.invoke(o, params);
} catch (IllegalArgumentException e) {
TestBase.logError("error", e);
} catch (IllegalAccessException e) {
} catch (IllegalArgumentException | IllegalAccessException e) {
TestBase.logError("error", e);
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
......
......@@ -80,9 +80,7 @@ class Statement {
player.assign(assignVariable, obj);
}
return obj;
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
......
......@@ -114,9 +114,7 @@ public class TestClassLoaderLeak extends TestBase {
if (c == null) {
try {
c = findClass(name);
} catch (SecurityException e) {
return super.loadClass(name, resolve);
} catch (ClassNotFoundException e) {
} catch (SecurityException | ClassNotFoundException e) {
return super.loadClass(name, resolve);
}
if (resolve) {
......
......@@ -102,10 +102,7 @@ public class TestFileSystem extends TestDb {
testFileSystem("split:" + getBaseDir() + "/fs");
testFileSystem("split:nioMapped:" + getBaseDir() + "/fs");
}
} catch (Exception e) {
e.printStackTrace();
throw e;
} catch (Error e) {
} catch (Exception | Error e) {
e.printStackTrace();
throw e;
} finally {
......
......@@ -274,9 +274,7 @@ public class BuildBase {
} catch (InvocationTargetException e) {
throw e.getCause();
}
} catch (Error e) {
throw e;
} catch (RuntimeException e) {
} catch (Error | RuntimeException e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
......
......@@ -499,9 +499,7 @@ public class MinimalPerfectHash<K> {
for (ByteArrayOutputStream temp : outList) {
out.write(temp.toByteArray());
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (IOException e) {
} catch (InterruptedException | IOException e) {
throw new RuntimeException(e);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论