core: change catch blocks for Android <19 (#6611)

Caught by lint warning during import
This commit is contained in:
Eric Gribkoff 2020-01-21 14:38:10 -08:00 committed by GitHub
parent 74cde7e8b4
commit 42f2e7f733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 10 deletions

View File

@ -576,8 +576,14 @@ public abstract class AbstractManagedChannelImplBuilder
recordStartedRpcs, recordStartedRpcs,
recordFinishedRpcs, recordFinishedRpcs,
recordRealTimeMetrics); recordRealTimeMetrics);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException } catch (ClassNotFoundException e) {
| InvocationTargetException e) { // Replace these separate catch statements with multicatch when Android min-API >= 19
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (NoSuchMethodException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (IllegalAccessException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (InvocationTargetException e) {
log.log(Level.FINE, "Unable to apply census stats", e); log.log(Level.FINE, "Unable to apply census stats", e);
} }
if (statsInterceptor != null) { if (statsInterceptor != null) {
@ -595,9 +601,15 @@ public abstract class AbstractManagedChannelImplBuilder
Method getClientInterceptroMethod = Method getClientInterceptroMethod =
censusTracingAccessor.getDeclaredMethod("getClientInterceptor"); censusTracingAccessor.getDeclaredMethod("getClientInterceptor");
tracingInterceptor = (ClientInterceptor) getClientInterceptroMethod.invoke(null); tracingInterceptor = (ClientInterceptor) getClientInterceptroMethod.invoke(null);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException } catch (ClassNotFoundException e) {
| InvocationTargetException e) { // Replace these separate catch statements with multicatch when Android min-API >= 19
log.log(Level.FINE, "Unable to apply census tracing", e); log.log(Level.FINE, "Unable to apply census stats", e);
} catch (NoSuchMethodException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (IllegalAccessException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (InvocationTargetException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} }
if (tracingInterceptor != null) { if (tracingInterceptor != null) {
effectiveInterceptors.add(0, tracingInterceptor); effectiveInterceptors.add(0, tracingInterceptor);

View File

@ -253,8 +253,14 @@ public abstract class AbstractServerImplBuilder<T extends AbstractServerImplBuil
recordStartedRpcs, recordStartedRpcs,
recordFinishedRpcs, recordFinishedRpcs,
recordRealTimeMetrics); recordRealTimeMetrics);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException } catch (ClassNotFoundException e) {
| InvocationTargetException e) { // Replace these separate catch statements with multicatch when Android min-API >= 19
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (NoSuchMethodException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (IllegalAccessException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (InvocationTargetException e) {
log.log(Level.FINE, "Unable to apply census stats", e); log.log(Level.FINE, "Unable to apply census stats", e);
} }
if (censusStatsTracerFactory != null) { if (censusStatsTracerFactory != null) {
@ -270,9 +276,15 @@ public abstract class AbstractServerImplBuilder<T extends AbstractServerImplBuil
censusTracingAccessor.getDeclaredMethod("getServerStreamTracerFactory"); censusTracingAccessor.getDeclaredMethod("getServerStreamTracerFactory");
tracingStreamTracerFactory = tracingStreamTracerFactory =
(ServerStreamTracer.Factory) getServerStreamTracerFactoryMethod.invoke(null); (ServerStreamTracer.Factory) getServerStreamTracerFactoryMethod.invoke(null);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException } catch (ClassNotFoundException e) {
| InvocationTargetException e) { // Replace these separate catch statements with multicatch when Android min-API >= 19
log.log(Level.FINE, "Unable to apply census tracing", e); log.log(Level.FINE, "Unable to apply census stats", e);
} catch (NoSuchMethodException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (IllegalAccessException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} catch (InvocationTargetException e) {
log.log(Level.FINE, "Unable to apply census stats", e);
} }
if (tracingStreamTracerFactory != null) { if (tracingStreamTracerFactory != null) {
tracerFactories.add(tracingStreamTracerFactory); tracerFactories.add(tracingStreamTracerFactory);