Formatting simplification for Java7

This commit is contained in:
Kohsuke Kawaguchi committed 2015-12-20 10:54:33 -08:00
1 parent 8bb812a930
commit c1a53a5f21
1 file changed
+14 -23
+14 -23
View File
@@ -37,6 +37,7 @@ import com.google.inject.Scope;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import com.google.common.collect.ImmutableList;
import hudson.init.InitMilestone;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import jenkins.ExtensionComponentSet;
@@ -244,7 +245,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
*/
private List<IndexItem<?,Object>> sezpozIndex;
private final Map<Key,Annotation> annotations = new HashMap<Key,Annotation>();
private final Map<Key,Annotation> annotations = new HashMap<>();
private final Sezpoz moduleFinder = new Sezpoz();
/**
@@ -260,7 +261,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
sezpozIndex = loadSezpozIndices(Jenkins.getInstance().getPluginManager().uberClassLoader);
List<Module> modules = new ArrayList<Module>();
List<Module> modules = new ArrayList<>();
modules.add(new AbstractModule() {
@Override
protected void configure() {
@@ -324,7 +325,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
l.addAll(delta);
sezpozIndex = l;
List<Module> modules = new ArrayList<Module>();
List<Module> modules = new ArrayList<>();
modules.add(new SezpozModule(delta));
for (ExtensionComponent<Module> ec : moduleFinder.refresh().find(Module.class)) {
modules.add(ec.getInstance());
@@ -337,7 +338,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
return new ExtensionComponentSet() {
@Override
public <T> Collection<ExtensionComponent<T>> find(Class<T> type) {
List<ExtensionComponent<T>> result = new ArrayList<ExtensionComponent<T>>();
List<ExtensionComponent<T>> result = new ArrayList<>();
_find(type, result, child);
return result;
}
@@ -351,14 +352,11 @@ public abstract class ExtensionFinder implements ExtensionPoint {
private Object instantiate(IndexItem<?,Object> item) {
try {
return item.instance();
} catch (LinkageError e) {
} catch (LinkageError | Exception e) {
// sometimes the instantiation fails in an indirect classloading failure,
// which results in a LinkageError
LOGGER.log(isOptional(item.annotation()) ? Level.FINE : Level.WARNING,
"Failed to load "+item.className(), e);
} catch (Exception e) {
LOGGER.log(isOptional(item.annotation()) ? Level.FINE : Level.WARNING,
"Failed to load "+item.className(), e);
}
return null;
}
@@ -375,7 +373,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
public <U> Collection<ExtensionComponent<U>> find(Class<U> type, Hudson jenkins) {
// the find method contract requires us to traverse all known components
List<ExtensionComponent<U>> result = new ArrayList<ExtensionComponent<U>>();
List<ExtensionComponent<U>> result = new ArrayList<>();
for (Injector i=container; i!=null; i=i.getParent()) {
_find(type, result, i);
}
@@ -389,7 +387,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
Object o = e.getValue().getProvider().get();
if (o!=null) {
GuiceExtensionAnnotation gea = a!=null ? extensionAnnotations.get(a.annotationType()) : null;
result.add(new ExtensionComponent<U>(type.cast(o),gea!=null?gea.getOrdinal(a):0));
result.add(new ExtensionComponent<>(type.cast(o), gea != null ? gea.getOrdinal(a) : 0));
}
}
}
@@ -443,7 +441,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
}
};
}
};
}
private static final Logger LOGGER = Logger.getLogger(GuiceFinder.class.getName());
@@ -532,14 +530,11 @@ public abstract class ExtensionFinder implements ExtensionPoint {
}
}).in(scope);
}
} catch (LinkageError e) {
} catch (Exception|LinkageError e) {
// sometimes the instantiation fails in an indirect classloading failure,
// which results in a LinkageError
LOGGER.log(optional ? Level.FINE : Level.WARNING,
"Failed to load "+item.className(), e);
} catch (Exception e) {
LOGGER.log(optional ? Level.FINE : Level.WARNING,
"Failed to load "+item.className(), e);
}
}
}
@@ -621,7 +616,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
* Finds all the matching {@link IndexItem}s that match the given type and instantiate them.
*/
private <T> Collection<ExtensionComponent<T>> _find(Class<T> type, List<IndexItem<Extension,Object>> indices) {
List<ExtensionComponent<T>> result = new ArrayList<ExtensionComponent<T>>();
List<ExtensionComponent<T>> result = new ArrayList<>();
for (IndexItem<Extension,Object> item : indices) {
try {
@@ -641,14 +636,12 @@ public abstract class ExtensionFinder implements ExtensionPoint {
if(type.isAssignableFrom(extType)) {
Object instance = item.instance();
if(instance!=null)
result.add(new ExtensionComponent<T>(type.cast(instance),item.annotation()));
result.add(new ExtensionComponent<>(type.cast(instance),item.annotation()));
}
} catch (LinkageError e) {
} catch (LinkageError|Exception e) {
// sometimes the instantiation fails in an indirect classloading failure,
// which results in a LinkageError
LOGGER.log(logLevel(item), "Failed to load "+item.className(), e);
} catch (Exception e) {
LOGGER.log(logLevel(item), "Failed to load "+item.className(), e);
}
}
@@ -678,9 +671,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
// according to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6459208
// this appears to be the only way to force a class initialization
Class.forName(extType.getName(),true,extType.getClassLoader());
} catch (Exception e) {
LOGGER.log(logLevel(item), "Failed to scout "+item.className(), e);
} catch (LinkageError e) {
} catch (Exception | LinkageError e) {
LOGGER.log(logLevel(item), "Failed to scout "+item.className(), e);
}
}