diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2019-06-22 18:40:49 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2019-06-22 18:44:23 +0900 |
commit | dad9e1ff95b292661bd3aec6292cf4ae4d62a5bb (patch) | |
tree | 47209bade33fee13e8d9ad58c8b915fdfabac4a5 /org.eclipse.jgit/src | |
parent | 99a5fa22834e830e043938883cd610a96a04528c (diff) | |
download | jgit-dad9e1ff95b292661bd3aec6292cf4ae4d62a5bb.tar.gz jgit-dad9e1ff95b292661bd3aec6292cf4ae4d62a5bb.zip |
GlobalBundleCache: Fix ClassNewInstance warning from Error Prone
Error Prone reports:
[ClassNewInstance] Class.newInstance() bypasses exception checking;
prefer getDeclaredConstructor().newInstance()
See https://errorprone.info/bugpattern/ClassNewInstance
This was the only occurrence of the warning in the code base; now it's
fixed, increase the severity to ERROR to prevent future occurrences.
Change-Id: Ic04d1c5d2bd458bbb4bb399d6ce9d147bd48d0b1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java index 84bf214607..b437f635f5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.nls; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -92,12 +93,13 @@ class GlobalBundleCache { } TranslationBundle bundle = bundles.get(type); if (bundle == null) { - bundle = type.newInstance(); + bundle = type.getDeclaredConstructor().newInstance(); bundle.load(locale); bundles.put(type, bundle); } return (T) bundle; - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException + | InvocationTargetException | NoSuchMethodException e) { throw new Error(e); } } |