提交 a80c1338 authored 作者: igor-suhorukov's avatar igor-suhorukov

Use multi-catch java 7 language construction to simplify code

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