Java 8 migration. Similar catch blocks joined (#8759)

Motivation:

Avoid IDE warnings, easier to read.

Modification:

Same catch blocks joined.

Result:

Cleanup
This commit is contained in:
Dmitriy Dumanskiy 2019-01-22 19:00:10 +02:00 committed by Norman Maurer
parent 42376c052a
commit 32d96a7f79
6 changed files with 22 additions and 76 deletions

View File

@ -599,11 +599,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
// error while decoding // error while decoding
undecodedChunk.readerIndex(firstpos); undecodedChunk.readerIndex(firstpos);
throw e; throw e;
} catch (IOException e) { } catch (IOException | IllegalArgumentException e) {
// error while decoding
undecodedChunk.readerIndex(firstpos);
throw new ErrorDataDecoderException(e);
} catch (IllegalArgumentException e) {
// error while decoding // error while decoding
undecodedChunk.readerIndex(firstpos); undecodedChunk.readerIndex(firstpos);
throw new ErrorDataDecoderException(e); throw new ErrorDataDecoderException(e);

View File

@ -235,14 +235,7 @@ public class DefaultHttp2ConnectionDecoder implements Http2ConnectionDecoder {
// immediately processed. // immediately processed.
bytesToReturn = listener.onDataRead(ctx, streamId, data, padding, endOfStream); bytesToReturn = listener.onDataRead(ctx, streamId, data, padding, endOfStream);
return bytesToReturn; return bytesToReturn;
} catch (Http2Exception e) { } catch (Http2Exception | RuntimeException e) {
// If an exception happened during delivery, the listener may have returned part
// of the bytes before the error occurred. If that's the case, subtract that from
// the total processed bytes so that we don't return too many bytes.
int delta = unconsumedBytes - unconsumedBytes(stream);
bytesToReturn -= delta;
throw e;
} catch (RuntimeException e) {
// If an exception happened during delivery, the listener may have returned part // If an exception happened during delivery, the listener may have returned part
// of the bytes before the error occurred. If that's the case, subtract that from // of the bytes before the error occurred. If that's the case, subtract that from
// the total processed bytes so that we don't return too many bytes. // the total processed bytes so that we don't return too many bytes.

View File

@ -46,11 +46,7 @@ final class CleanerJava9 implements Cleaner {
"invokeCleaner", ByteBuffer.class); "invokeCleaner", ByteBuffer.class);
m.invoke(PlatformDependent0.UNSAFE, buffer); m.invoke(PlatformDependent0.UNSAFE, buffer);
return m; return m;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
return e;
} catch (InvocationTargetException e) {
return e;
} catch (IllegalAccessException e) {
return e; return e;
} }
} }
@ -100,9 +96,7 @@ final class CleanerJava9 implements Cleaner {
public Exception run() { public Exception run() {
try { try {
INVOKE_CLEANER.invoke(PlatformDependent0.UNSAFE, buffer); INVOKE_CLEANER.invoke(PlatformDependent0.UNSAFE, buffer);
} catch (InvocationTargetException e) { } catch (InvocationTargetException | IllegalAccessException e) {
return e;
} catch (IllegalAccessException e) {
return e; return e;
} }
return null; return null;

View File

@ -93,17 +93,11 @@ final class PlatformDependent0 {
} }
// the unsafe instance // the unsafe instance
return unsafeField.get(null); return unsafeField.get(null);
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException | SecurityException
| IllegalAccessException | NoClassDefFoundError e) {
return e; return e;
} catch (SecurityException e) { } // Also catch NoClassDefFoundError in case someone uses for example OSGI and it made
return e; // Unsafe unloadable.
} catch (IllegalAccessException e) {
return e;
} catch (NoClassDefFoundError e) {
// Also catch NoClassDefFoundError in case someone uses for example OSGI and it made
// Unsafe unloadable.
return e;
}
} }
}); });
@ -132,9 +126,7 @@ final class PlatformDependent0 {
finalUnsafe.getClass().getDeclaredMethod( finalUnsafe.getClass().getDeclaredMethod(
"copyMemory", Object.class, long.class, Object.class, long.class, long.class); "copyMemory", Object.class, long.class, Object.class, long.class, long.class);
return null; return null;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | SecurityException e) {
return e;
} catch (SecurityException e) {
return e; return e;
} }
} }
@ -169,9 +161,7 @@ final class PlatformDependent0 {
return null; return null;
} }
return field; return field;
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException | SecurityException e) {
return e;
} catch (SecurityException e) {
return e; return e;
} }
} }
@ -226,9 +216,7 @@ final class PlatformDependent0 {
return cause; return cause;
} }
return constructor; return constructor;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | SecurityException e) {
return e;
} catch (SecurityException e) {
return e; return e;
} }
} }
@ -241,11 +229,7 @@ final class PlatformDependent0 {
((Constructor<?>) maybeDirectBufferConstructor).newInstance(address, 1); ((Constructor<?>) maybeDirectBufferConstructor).newInstance(address, 1);
directBufferConstructor = (Constructor<?>) maybeDirectBufferConstructor; directBufferConstructor = (Constructor<?>) maybeDirectBufferConstructor;
logger.debug("direct buffer constructor: available"); logger.debug("direct buffer constructor: available");
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
directBufferConstructor = null;
} catch (IllegalAccessException e) {
directBufferConstructor = null;
} catch (InvocationTargetException e) {
directBufferConstructor = null; directBufferConstructor = null;
} }
} else { } else {
@ -294,15 +278,8 @@ final class PlatformDependent0 {
return cause; return cause;
} }
return unalignedMethod.invoke(null); return unalignedMethod.invoke(null);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | SecurityException
return e; | IllegalAccessException | ClassNotFoundException | InvocationTargetException e) {
} catch (SecurityException e) {
return e;
} catch (IllegalAccessException e) {
return e;
} catch (ClassNotFoundException e) {
return e;
} catch (InvocationTargetException e) {
return e; return e;
} }
} }
@ -346,9 +323,7 @@ final class PlatformDependent0 {
try { try {
return finalInternalUnsafe.getClass().getDeclaredMethod( return finalInternalUnsafe.getClass().getDeclaredMethod(
"allocateUninitializedArray", Class.class, int.class); "allocateUninitializedArray", Class.class, int.class);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | SecurityException e) {
return e;
} catch (SecurityException e) {
return e; return e;
} }
} }
@ -360,9 +335,7 @@ final class PlatformDependent0 {
byte[] bytes = (byte[]) m.invoke(finalInternalUnsafe, byte.class, 8); byte[] bytes = (byte[]) m.invoke(finalInternalUnsafe, byte.class, 8);
assert bytes.length == 8; assert bytes.length == 8;
allocateArrayMethod = m; allocateArrayMethod = m;
} catch (IllegalAccessException e) { } catch (IllegalAccessException | InvocationTargetException e) {
maybeException = e;
} catch (InvocationTargetException e) {
maybeException = e; maybeException = e;
} }
} }
@ -459,9 +432,7 @@ final class PlatformDependent0 {
static byte[] allocateUninitializedArray(int size) { static byte[] allocateUninitializedArray(int size) {
try { try {
return (byte[]) ALLOCATE_ARRAY_METHOD.invoke(INTERNAL_UNSAFE, byte.class, size); return (byte[]) ALLOCATE_ARRAY_METHOD.invoke(INTERNAL_UNSAFE, byte.class, size);
} catch (IllegalAccessException e) { } catch (IllegalAccessException | InvocationTargetException e) {
throw new Error(e);
} catch (InvocationTargetException e) {
throw new Error(e); throw new Error(e);
} }
} }

View File

@ -119,9 +119,7 @@ final class OpenSslX509TrustManagerWrapper {
} while (clazz != null); } while (clazz != null);
} }
throw new NoSuchFieldException(); throw new NoSuchFieldException();
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException | SecurityException e) {
return e;
} catch (SecurityException e) {
return e; return e;
} }
} }
@ -174,11 +172,7 @@ final class OpenSslX509TrustManagerWrapper {
return (X509TrustManager) tm; return (X509TrustManager) tm;
} }
} }
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException | KeyManagementException e) {
// This should never happen as we did the same in the static
// before.
PlatformDependent.throwException(e);
} catch (KeyManagementException e) {
// This should never happen as we did the same in the static // This should never happen as we did the same in the static
// before. // before.
PlatformDependent.throwException(e); PlatformDependent.throwException(e);

View File

@ -276,9 +276,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
selectedKeysField.set(unwrappedSelector, selectedKeySet); selectedKeysField.set(unwrappedSelector, selectedKeySet);
publicSelectedKeysField.set(unwrappedSelector, selectedKeySet); publicSelectedKeysField.set(unwrappedSelector, selectedKeySet);
return null; return null;
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException | IllegalAccessException e) {
return e;
} catch (IllegalAccessException e) {
return e; return e;
} }
} }
@ -311,8 +309,8 @@ public final class NioEventLoop extends SingleThreadEventLoop {
@Override @Override
protected Queue<Runnable> newTaskQueue(int maxPendingTasks) { protected Queue<Runnable> newTaskQueue(int maxPendingTasks) {
// This event loop never calls takeTask() // This event loop never calls takeTask()
return maxPendingTasks == Integer.MAX_VALUE ? PlatformDependent.<Runnable>newMpscQueue() return maxPendingTasks == Integer.MAX_VALUE ? PlatformDependent.newMpscQueue()
: PlatformDependent.<Runnable>newMpscQueue(maxPendingTasks); : PlatformDependent.newMpscQueue(maxPendingTasks);
} }
/** /**