From cfb6bd0fe23fc88c6f28bc773835dd8c61cad59d Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 8 Dec 2016 10:19:08 -0800 Subject: [PATCH] context: Fix ErrorProne ClassNewInstance http://errorprone.info/bugpattern/ClassNewInstance --- context/src/main/java/io/grpc/Context.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/context/src/main/java/io/grpc/Context.java b/context/src/main/java/io/grpc/Context.java index 68db7521c7..db7aaf7ab9 100644 --- a/context/src/main/java/io/grpc/Context.java +++ b/context/src/main/java/io/grpc/Context.java @@ -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();