mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 20:12:14 +00:00
Enable whitespace-related Checkstyle checks (#6149)
This commit is contained in:
1 parent
1068567cb4
commit
e27b310065
1322 files changed
+13269
-11069
No files matched your search
@@ -21,6 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package hudson;
|
||||
|
||||
import static org.apache.commons.io.FilenameUtils.getBaseName;
|
||||
@@ -160,7 +161,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
if (isLinked) {
|
||||
manifest = loadLinkedManifest(archive);
|
||||
} else {
|
||||
if (archive.isDirectory()) {// already expanded
|
||||
if (archive.isDirectory()) { // already expanded
|
||||
expandDir = archive;
|
||||
} else {
|
||||
File f = pluginManager.getWorkDir();
|
||||
@@ -195,7 +196,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
parseClassPath(manifest, archive, paths, "Libraries", ",");
|
||||
parseClassPath(manifest, archive, paths, "Class-Path", " +"); // backward compatibility
|
||||
|
||||
baseResourceURL = resolve(archive,atts.getValue("Resource-Path")).toURI().toURL();
|
||||
baseResourceURL = resolve(archive, atts.getValue("Resource-Path")).toURI().toURL();
|
||||
} else {
|
||||
File classes = new File(expandDir, "WEB-INF/classes");
|
||||
if (classes.exists()) { // should not normally happen, due to createClassJarFromWebInfClasses
|
||||
@@ -233,18 +234,18 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
fix(atts,optionalDependencies);
|
||||
fix(atts, optionalDependencies);
|
||||
|
||||
// Register global classpath mask. This is useful for hiding JavaEE APIs that you might see from the container,
|
||||
// such as database plugin for JPA support. The Mask-Classes attribute is insufficient because those classes
|
||||
// also need to be masked by all the other plugins that depend on the database plugin.
|
||||
String masked = atts.getValue("Global-Mask-Classes");
|
||||
if(masked!=null) {
|
||||
if (masked != null) {
|
||||
for (String pkg : masked.trim().split("[ \t\r\n]+"))
|
||||
coreClassLoader.add(pkg);
|
||||
}
|
||||
|
||||
ClassLoader dependencyLoader = new DependencyClassLoader(coreClassLoader, archive, Util.join(dependencies,optionalDependencies), pluginManager);
|
||||
ClassLoader dependencyLoader = new DependencyClassLoader(coreClassLoader, archive, Util.join(dependencies, optionalDependencies), pluginManager);
|
||||
dependencyLoader = getBaseClassLoader(atts, dependencyLoader);
|
||||
|
||||
return new PluginWrapper(pluginManager, archive, manifest, baseResourceURL,
|
||||
@@ -255,7 +256,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
String pluginName = atts.getValue("Short-Name");
|
||||
|
||||
String jenkinsVersion = atts.getValue("Jenkins-Version");
|
||||
if (jenkinsVersion==null)
|
||||
if (jenkinsVersion == null)
|
||||
jenkinsVersion = atts.getValue("Hudson-Version");
|
||||
|
||||
for (Dependency d : DetachedPluginsUtil.getImpliedDependencies(pluginName, jenkinsVersion)) {
|
||||
@@ -278,7 +279,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
|
||||
@Deprecated
|
||||
protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent) throws IOException {
|
||||
return createClassLoader( paths, parent, null );
|
||||
return createClassLoader(paths, parent, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +323,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
*/
|
||||
private ClassLoader getBaseClassLoader(Attributes atts, ClassLoader base) {
|
||||
String masked = atts.getValue("Mask-Classes");
|
||||
if(masked!=null)
|
||||
if (masked != null)
|
||||
base = new MaskingClassLoader(base, masked.trim().split("[ \t\r\n]+"));
|
||||
return base;
|
||||
}
|
||||
@@ -335,7 +336,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
public <T> List<ExtensionComponent<T>> findComponents(Class<T> type, Hudson hudson) {
|
||||
|
||||
List<ExtensionFinder> finders;
|
||||
if (type==ExtensionFinder.class) {
|
||||
if (type == ExtensionFinder.class) {
|
||||
// Avoid infinite recursion of using ExtensionFinders to find ExtensionFinders
|
||||
finders = Collections.singletonList(new ExtensionFinder.Sezpoz());
|
||||
} else {
|
||||
@@ -346,7 +347,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
* See ExtensionFinder#scout(Class, Hudson) for the dead lock issue and what this does.
|
||||
*/
|
||||
if (LOGGER.isLoggable(Level.FINER))
|
||||
LOGGER.log(Level.FINER, "Scout-loading ExtensionList: "+type, new Throwable());
|
||||
LOGGER.log(Level.FINER, "Scout-loading ExtensionList: " + type, new Throwable());
|
||||
for (ExtensionFinder finder : finders) {
|
||||
finder.scout(type, hudson);
|
||||
}
|
||||
@@ -364,7 +365,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
|
||||
List<ExtensionComponent<T>> filtered = new ArrayList<>();
|
||||
for (ExtensionComponent<T> e : r) {
|
||||
if (ExtensionFilter.isAllowed(type,e))
|
||||
if (ExtensionFilter.isAllowed(type, e))
|
||||
filtered.add(e);
|
||||
}
|
||||
|
||||
@@ -379,21 +380,21 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
Thread.currentThread().setContextClassLoader(wrapper.classLoader);
|
||||
try {
|
||||
String className = wrapper.getPluginClass();
|
||||
if(className==null) {
|
||||
if (className == null) {
|
||||
// use the default dummy instance
|
||||
wrapper.setPlugin(new DummyImpl());
|
||||
} else {
|
||||
try {
|
||||
Class<?> clazz = wrapper.classLoader.loadClass(className);
|
||||
Object o = clazz.getDeclaredConstructor().newInstance();
|
||||
if(!(o instanceof Plugin)) {
|
||||
throw new IOException(className+" doesn't extend from hudson.Plugin");
|
||||
if (!(o instanceof Plugin)) {
|
||||
throw new IOException(className + " doesn't extend from hudson.Plugin");
|
||||
}
|
||||
wrapper.setPlugin((Plugin) o);
|
||||
} catch (LinkageError | ClassNotFoundException e) {
|
||||
throw new IOException("Unable to load " + className + " from " + wrapper.getShortName(),e);
|
||||
throw new IOException("Unable to load " + className + " from " + wrapper.getShortName(), e);
|
||||
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new IOException("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
|
||||
throw new IOException("Unable to create instance of " + className + " from " + wrapper.getShortName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,9 +403,9 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
Plugin plugin = wrapper.getPluginOrFail();
|
||||
plugin.setServletContext(pluginManager.context);
|
||||
startPlugin(wrapper);
|
||||
} catch(Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
// gracefully handle any error in plugin.
|
||||
throw new IOException("Failed to initialize",t);
|
||||
throw new IOException("Failed to initialize", t);
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
@@ -428,14 +429,14 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
{
|
||||
for (; classLoader != null; classLoader = classLoader.getParent()) {
|
||||
if (classLoader instanceof DependencyClassLoader) {
|
||||
return (DependencyClassLoader)classLoader;
|
||||
return (DependencyClassLoader) classLoader;
|
||||
}
|
||||
|
||||
if (classLoader instanceof AntClassLoader) {
|
||||
// AntClassLoaders hold parents not only as AntClassLoader#getParent()
|
||||
// but also as AntClassLoader#getConfiguredParent()
|
||||
DependencyClassLoader ret = findAncestorDependencyClassLoader(
|
||||
((AntClassLoader)classLoader).getConfiguredParent()
|
||||
((AntClassLoader) classLoader).getConfiguredParent()
|
||||
);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
@@ -448,29 +449,29 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "Administrator action installing a plugin, which could do far worse.")
|
||||
private static File resolve(File base, String relative) {
|
||||
File rel = new File(relative);
|
||||
if(rel.isAbsolute())
|
||||
if (rel.isAbsolute())
|
||||
return rel;
|
||||
else
|
||||
return new File(base.getParentFile(),relative);
|
||||
return new File(base.getParentFile(), relative);
|
||||
}
|
||||
|
||||
private static void parseClassPath(Manifest manifest, File archive, List<File> paths, String attributeName, String separator) throws IOException {
|
||||
String classPath = manifest.getMainAttributes().getValue(attributeName);
|
||||
if(classPath==null) return; // attribute not found
|
||||
if (classPath == null) return; // attribute not found
|
||||
for (String s : classPath.split(separator)) {
|
||||
File file = resolve(archive, s);
|
||||
if(file.getName().contains("*")) {
|
||||
if (file.getName().contains("*")) {
|
||||
// handle wildcard
|
||||
FileSet fs = new FileSet();
|
||||
File dir = file.getParentFile();
|
||||
fs.setDir(dir);
|
||||
fs.setIncludes(file.getName());
|
||||
for( String included : fs.getDirectoryScanner(new Project()).getIncludedFiles() ) {
|
||||
paths.add(new File(dir,included));
|
||||
for (String included : fs.getDirectoryScanner(new Project()).getIncludedFiles()) {
|
||||
paths.add(new File(dir, included));
|
||||
}
|
||||
} else {
|
||||
if(!file.exists())
|
||||
throw new IOException("No such file: "+file);
|
||||
if (!file.exists())
|
||||
throw new IOException("No such file: " + file);
|
||||
paths.add(file);
|
||||
}
|
||||
}
|
||||
@@ -483,8 +484,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
Util.createDirectories(Util.fileToPath(destDir));
|
||||
|
||||
// timestamp check
|
||||
File explodeTime = new File(destDir,".timestamp2");
|
||||
if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
|
||||
File explodeTime = new File(destDir, ".timestamp2");
|
||||
if (explodeTime.exists() && explodeTime.lastModified() == archive.lastModified())
|
||||
return; // no need to expand
|
||||
|
||||
// delete the contents so that old files won't interfere with new files
|
||||
@@ -495,7 +496,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
unzipExceptClasses(archive, destDir, prj);
|
||||
createClassJarFromWebInfClasses(archive, destDir, prj);
|
||||
} catch (BuildException x) {
|
||||
throw new IOException("Failed to expand " + archive,x);
|
||||
throw new IOException("Failed to expand " + archive, x);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -530,7 +531,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
try (ZipOutputStream wrappedZOut = new ZipOutputStream(NullOutputStream.NULL_OUTPUT_STREAM) {
|
||||
@Override
|
||||
public void putNextEntry(ZipEntry ze) throws IOException {
|
||||
ze.setTime(dirTime+1999); // roundup
|
||||
ze.setTime(dirTime + 1999); // roundup
|
||||
super.putNextEntry(ze);
|
||||
}
|
||||
}) {
|
||||
@@ -544,7 +545,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
int mode, ZipExtraField[] extra)
|
||||
throws IOException {
|
||||
// use wrappedZOut instead of zOut
|
||||
super.zipDir(dir,wrappedZOut,vPath,mode,extra);
|
||||
super.zipDir(dir, wrappedZOut, vPath, mode, extra);
|
||||
}
|
||||
};
|
||||
z.setProject(prj);
|
||||
@@ -617,7 +618,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
List<PluginWrapper> dep = new ArrayList<>();
|
||||
for (Dependency d : pw.getDependencies()) {
|
||||
PluginWrapper p = pluginManager.getPlugin(d.shortName);
|
||||
if (p!=null && p.isActive())
|
||||
if (p != null && p.isActive())
|
||||
dep.add(p);
|
||||
}
|
||||
return dep;
|
||||
@@ -627,7 +628,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
try {
|
||||
for (Dependency d : dependencies) {
|
||||
PluginWrapper p = pluginManager.getPlugin(d.shortName);
|
||||
if (p!=null && p.isActive())
|
||||
if (p != null && p.isActive())
|
||||
cgd.run(Collections.singleton(p));
|
||||
}
|
||||
} catch (CycleDetectedException e) {
|
||||
@@ -654,7 +655,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
} else {
|
||||
for (Dependency dep : dependencies) {
|
||||
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
|
||||
if(p!=null) {
|
||||
if (p != null) {
|
||||
try {
|
||||
return p.classLoader.loadClass(name);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
@@ -682,7 +683,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
} else {
|
||||
for (Dependency dep : dependencies) {
|
||||
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
|
||||
if (p!=null) {
|
||||
if (p != null) {
|
||||
Enumeration<URL> urls = p.classLoader.getResources(name);
|
||||
while (urls != null && urls.hasMoreElements())
|
||||
result.add(urls.nextElement());
|
||||
@@ -698,14 +699,14 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
if (PluginManager.FAST_LOOKUP) {
|
||||
for (PluginWrapper pw : getTransitiveDependencies()) {
|
||||
URL url = ClassLoaderReflectionToolkit._findResource(pw.classLoader, name);
|
||||
if (url!=null) return url;
|
||||
if (url != null) return url;
|
||||
}
|
||||
} else {
|
||||
for (Dependency dep : dependencies) {
|
||||
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
|
||||
if(p!=null) {
|
||||
if (p != null) {
|
||||
URL url = p.classLoader.getResource(name);
|
||||
if (url!=null)
|
||||
if (url != null)
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user