context: Fix ErrorProne ClassNewInstance

http://errorprone.info/bugpattern/ClassNewInstance
This commit is contained in:
Eric Anderson 2016-12-08 10:19:08 -08:00
parent 21bca9a475
commit cfb6bd0fe2
1 changed files with 2 additions and 4 deletions

View File

@ -128,13 +128,11 @@ public class Context {
}
try {
Class<?> clazz = Class.forName("io.grpc.ContextStorageOverride");
storage = (Storage) clazz.newInstance();
storage = (Storage) clazz.getConstructor().newInstance();
return storage;
} catch (ClassNotFoundException e) {
log.log(Level.FINE, "Storage override doesn't exist. Using default.", e);
} catch (InstantiationException e) {
throw new RuntimeException("Failed to initialize Storage implementation", e);
} catch (IllegalAccessException e) {
} catch (Exception e) {
throw new RuntimeException("Failed to initialize Storage implementation", e);
}
storage = new ThreadLocalContextStorage();