Explorar el Código

Use only a single instance for NLS translation bundles

As findbugs pointed out, there was a small risk for creating multiple instances of
translation bundles. If that happens, drop the second instance.

Change-Id: I3aacda86251d511f6bbc2ed7481d561449ce3b6c
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
tags/v0.10.1
Robin Rosenberg hace 13 años
padre
commit
be9d096986
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6
    1
      org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java

+ 6
- 1
org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java Ver fichero

@@ -125,11 +125,16 @@ public class NLS {
this.locale = locale;
}

@SuppressWarnings("unchecked")
private <T extends TranslationBundle> T get(Class<T> type) {
TranslationBundle bundle = map.get(type);
if (bundle == null) {
bundle = GlobalBundleCache.lookupBundle(locale, type);
map.putIfAbsent(type, bundle);
// There is a small opportunity for a race, which we may
// lose. Accept defeat and return the winner's instance.
TranslationBundle old = map.putIfAbsent(type, bundle);
if (old != null)
bundle = old;
}
return (T) bundle;
}

Cargando…
Cancelar
Guardar