提交 239948d4 编写于 作者: J jglick

Some compiler lint.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1236 71c3de6d-444a-0410-be80-ed276b4c234a
上级 2f381a81
......@@ -17,6 +17,7 @@ public class EnvVars {
public static final Map<String,String> masterEnvVars;
static {
@SuppressWarnings("unchecked") // Ant does not use JDK 5
Vector<String> envs = Execute.getProcEnvironment();
Map<String,String> m = new HashMap<String,String>();
for (String e : envs) {
......
......@@ -62,7 +62,8 @@ public class Functions {
}
public static RunUrl decompose(StaplerRequest req) {
List<Ancestor> ancestors = (List<Ancestor>) req.getAncestors();
@SuppressWarnings("unchecked") // pre-JDK 5 API?
List<Ancestor> ancestors = req.getAncestors();
for (Ancestor anc : ancestors) {
if(anc.getObject() instanceof Run) {
// bingo
......@@ -139,11 +140,11 @@ public class Functions {
}
public static Map getSystemProperties() {
return new TreeMap(System.getProperties());
return new TreeMap<Object,Object>(System.getProperties());
}
public static Map getEnvVars() {
return new TreeMap(EnvVars.masterEnvVars);
return new TreeMap<String,String>(EnvVars.masterEnvVars);
}
public static boolean isWindows() {
......
......@@ -36,15 +36,15 @@ public class Launcher {
this.listener = listener;
}
public final Proc launch(String cmd, Map env, OutputStream out, FilePath workDir) throws IOException {
public final Proc launch(String cmd, Map<String,String> env, OutputStream out, FilePath workDir) throws IOException {
return launch(cmd,Util.mapToEnv(env),out,workDir);
}
public final Proc launch(String[] cmd, Map env, OutputStream out, FilePath workDir) throws IOException {
public final Proc launch(String[] cmd, Map<String,String> env, OutputStream out, FilePath workDir) throws IOException {
return launch(cmd,Util.mapToEnv(env),out,workDir);
}
public final Proc launch(String[] cmd,Map env, InputStream in, OutputStream out) throws IOException {
public final Proc launch(String[] cmd, Map<String,String> env, InputStream in, OutputStream out) throws IOException {
return launch(cmd,Util.mapToEnv(env),in,out);
}
......
package hudson;
import hudson.model.Hudson;
import hudson.scm.SCM;
import hudson.tasks.Builder;
import hudson.tasks.Publisher;
import hudson.triggers.Trigger;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......
......@@ -20,11 +20,11 @@ public final class Proc {
private final Process proc;
private final Thread t1,t2;
public Proc(String cmd,Map env, OutputStream out, File workDir) throws IOException {
public Proc(String cmd, Map<String,String> env, OutputStream out, File workDir) throws IOException {
this(cmd,Util.mapToEnv(env),out,workDir);
}
public Proc(String[] cmd,Map env,InputStream in, OutputStream out) throws IOException {
public Proc(String[] cmd, Map<String,String> env,InputStream in, OutputStream out) throws IOException {
this(cmd,Util.mapToEnv(env),in,out);
}
......
......@@ -17,7 +17,6 @@ import java.util.Map;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.util.SimpleTimeZone;
import java.util.Map.Entry;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.regex.Matcher;
......@@ -187,12 +186,12 @@ public class Util {
return a;
}
public static String[] mapToEnv(Map<?,?> m) {
public static String[] mapToEnv(Map<String,String> m) {
String[] r = new String[m.size()];
int idx=0;
for (final Map.Entry e : m.entrySet()) {
r[idx++] = e.getKey().toString() + '=' + e.getValue().toString();
for (final Map.Entry<String,String> e : m.entrySet()) {
r[idx++] = e.getKey() + '=' + e.getValue();
}
return r;
}
......
......@@ -2,13 +2,11 @@ package hudson;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.io.StreamException;
import com.thoughtworks.xstream.io.xml.XppReader;
import hudson.util.AtomicFileWriter;
import hudson.util.IOException2;
import hudson.util.XStream2;
import hudson.model.Descriptor;
import java.io.BufferedReader;
import java.io.File;
......
......@@ -36,8 +36,11 @@ public abstract class Actionable extends AbstractModelObject {
public <T extends Action> T getAction(Class<T> type) {
for (Action a : getActions()) {
if(type.isInstance(a))
return (T)a; // type.cast() not available in JDK 1.4
if (type.isInstance(a)) {
@SuppressWarnings("unchecked") // type.cast() not available in JDK 1.4; XXX doesn't retro* emulate it?
T _a = (T) a;
return _a;
}
}
return null;
}
......
......@@ -240,10 +240,10 @@ public final class Build extends Run<Project,Build> implements Runnable {
* Gets the changes in the dependency between the given build and this build.
*/
public Map<Project,DependencyChange> getDependencyChanges(Build from) {
if(from==null) return Collections.EMPTY_MAP; // make it easy to call this from views
if(from==null) return Collections.emptyMap(); // make it easy to call this from views
FingerprintAction n = this.getAction(FingerprintAction.class);
FingerprintAction o = from.getAction(FingerprintAction.class);
if(n==null || o==null) return Collections.EMPTY_MAP;
if(n==null || o==null) return Collections.emptyMap();
Map<Project,Integer> ndep = n.getDependencies();
Map<Project,Integer> odep = o.getDependencies();
......
package hudson.model;
import hudson.XmlFile;
import hudson.scm.CVSSCM;
import org.kohsuke.stapler.StaplerRequest;
import javax.servlet.http.HttpServletRequest;
......@@ -61,6 +60,7 @@ public abstract class Descriptor<T extends Describable<T>> {
*
* @deprecated
*/
@Deprecated
private transient Map<String,Object> properties;
/**
......@@ -113,6 +113,7 @@ public abstract class Descriptor<T extends Describable<T>> {
* @deprecated
* As of 1.64. Use {@link #configure(StaplerRequest)}.
*/
@Deprecated
public boolean configure( HttpServletRequest req ) throws FormException {
return true;
}
......@@ -162,7 +163,9 @@ public abstract class Descriptor<T extends Describable<T>> {
Object o = file.unmarshal(this);
if(o instanceof Map) {
// legacy format
convert((Map<String,Object>)o);
@SuppressWarnings("unchecked")
Map<String,Object> _o = (Map) o;
convert(_o);
save(); // convert to the new format
}
} catch (IOException e) {
......
......@@ -161,10 +161,11 @@ public final class Hudson extends JobCollection implements Node {
}
/**
* If you are calling it o Hudson something is wrong.
* If you are calling this on Hudson something is wrong.
*
* @deprecated
*/
@Deprecated
public String getNodeName() {
return "";
}
......@@ -339,6 +340,7 @@ public final class Hudson extends JobCollection implements Node {
* @deprecated
* why are you calling a method that always return true?
*/
@Deprecated
public boolean containsJob(Job job) {
return true;
}
......@@ -939,6 +941,7 @@ public final class Hudson extends JobCollection implements Node {
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
// Parse the request
@SuppressWarnings("unchecked") // pre-generics lib
List<FileItem> items = upload.parseRequest(req);
rsp.sendRedirect2(req.getContextPath()+"/fingerprint/"+
......@@ -1161,7 +1164,7 @@ public final class Hudson extends JobCollection implements Node {
/**
* Live view of recent {@link LogRecord}s produced by Hudson.
*/
public static List<LogRecord> logRecords = Collections.EMPTY_LIST; // initialized to dummy value to avoid NPE
public static List<LogRecord> logRecords = Collections.emptyList(); // initialized to dummy value to avoid NPE
/**
* Thread-safe reusable {@link XStream}.
......
......@@ -34,7 +34,6 @@ import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.SortedMap;
import java.util.Collections;
......@@ -310,6 +309,7 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
* This is only used to support backward compatibility with
* old URLs.
*/
@Deprecated
public RunT getBuild(String id) {
for (RunT r : _getRuns().values()) {
if(r.getId().equals(id))
......
......@@ -16,6 +16,7 @@ public abstract class JobDescriptor<J extends Job<J,R>,R extends Run<J,R>> exten
* @deprecated
* This is not a valid operation for {@link Job}s.
*/
@Deprecated
public Job<J,R> newInstance(StaplerRequest req) throws FormException {
throw new UnsupportedOperationException();
}
......
......@@ -11,13 +11,14 @@ public class Jobs {
/**
* List of all installed job types.
*/
public static final List<JobDescriptor> JOBS = (List)Descriptor.toList(
@SuppressWarnings("unchecked") // two typing problems here!
public static final List<JobDescriptor<?,?>> JOBS = (List)Descriptor.toList(
Project.DESCRIPTOR,
ExternalJob.DESCRIPTOR
);
public static JobDescriptor getDescriptor(String displayName) {
for (JobDescriptor job : JOBS) {
for (JobDescriptor<?,?> job : JOBS) {
if(job.getDisplayName().equals(displayName))
return job;
}
......
......@@ -516,7 +516,7 @@ public class Project extends Job<Project,Build> {
*/
public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
Set<Project> upstream = Collections.EMPTY_SET;
Set<Project> upstream = Collections.emptySet();
synchronized(this) {
try {
......@@ -711,6 +711,7 @@ public class Project extends Job<Project,Build> {
* @deprecated
* left for legacy config file compatibility
*/
@Deprecated
private transient String slave;
private static final String FAILURE_ONLY_COOKIE = "TestResultAction_failureOnly";
......
......@@ -7,7 +7,6 @@ import hudson.ExtensionPoint;
import hudson.Util;
import hudson.XmlFile;
import hudson.FeedAdapter;
import hudson.tasks.BuildStep;
import hudson.tasks.LogRotator;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.util.CharSpool;
......@@ -459,6 +458,10 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
Util.deleteRecursive(tmp);
removeRunFromParent();
}
@SuppressWarnings("unchecked") // seems this is too clever for Java's type system?
private void removeRunFromParent() {
getParent().removeRun((RunT)this);
}
......
......@@ -3,7 +3,6 @@ package hudson.scm;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Proc;
import hudson.model.BuildListener;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
......@@ -30,7 +29,7 @@ abstract class AbstractCVSFamilySCM implements SCM {
* Receives output from the executed program.
*/
protected final boolean run(Launcher launcher, ArgumentListBuilder cmd, TaskListener listener, FilePath dir, OutputStream out) throws IOException {
Map env = createEnvVarMap(true);
Map<String,String> env = createEnvVarMap(true);
int r = launcher.launch(cmd.toCommandArray(),env,out,dir).join();
if(r!=0)
......@@ -52,8 +51,8 @@ abstract class AbstractCVSFamilySCM implements SCM {
* false to indicate that the map should contain complete map.
* This is to invoke {@link Proc} directly.
*/
protected final Map createEnvVarMap(boolean overrideOnly) {
Map env = new HashMap();
protected final Map<String,String> createEnvVarMap(boolean overrideOnly) {
Map<String,String> env = new HashMap<String,String>();
if(!overrideOnly)
env.putAll(EnvVars.masterEnvVars);
buildEnvVars(env);
......
......@@ -28,7 +28,6 @@ import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
......@@ -274,6 +273,7 @@ public class CVSSCM extends AbstractCVSFamilySCM {
parseUpdateOutput("",baos, changedFileNames);
} else {
@SuppressWarnings("unchecked") // StringTokenizer oddly has the wrong type
Set<String> moduleNames = new TreeSet(Collections.list(new StringTokenizer(module)));
// Add in any existing CVS dirs, in case project checked out its own.
File[] subdirs = workspace.getLocal().listFiles();
......
......@@ -21,7 +21,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
/**
* Constant instance that represents no changes.
*/
public static final ChangeLogSet<? extends Entry> EMPTY = new CVSChangeLogSet(Collections.EMPTY_LIST);
public static final ChangeLogSet<? extends Entry> EMPTY = new CVSChangeLogSet(Collections.<CVSChangeLogSet.CVSChangeLog>emptyList());
public static abstract class Entry {
......
......@@ -11,7 +11,7 @@ import java.io.IOException;
* @author Kohsuke Kawaguchi
*/
public class NullChangeLogParser extends ChangeLogParser {
public ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException {
public ChangeLogSet<? extends ChangeLogSet.Entry> parse(Build build, File changelogFile) throws IOException, SAXException {
return ChangeLogSet.EMPTY;
}
}
......@@ -11,6 +11,7 @@ public class SCMS {
/**
* List of all installed SCMs.
*/
@SuppressWarnings("unchecked") // generic array creation
public static final List<Descriptor<SCM>> SCMS =
Descriptor.toList(NullSCM.DESCRIPTOR,CVSSCM.DESCRIPTOR,SubversionSCM.DESCRIPTOR);
}
......@@ -17,7 +17,6 @@ import org.kohsuke.stapler.StaplerResponse;
import org.xml.sax.SAXException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
......@@ -115,7 +114,7 @@ public class SubversionSCM extends AbstractCVSFamilySCM {
Map<String,Integer> previousRevisions = parseRevisionFile(build.getPreviousBuild());
Map<String,Integer> thisRevisions = parseRevisionFile(build);
Map env = createEnvVarMap(true);
Map<String,String> env = createEnvVarMap(true);
for( String module : getModuleDirNames() ) {
Integer prevRev = previousRevisions.get(module);
......
......@@ -22,7 +22,6 @@ import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册