提交 15ac490a 编写于 作者: J Jesse Glick

Now that we use Java 6, can finally deprecate IOException2.

上级 dbf1ea07
......@@ -29,7 +29,6 @@ import hudson.PluginWrapper.Dependency;
import hudson.model.Hudson;
import hudson.util.CyclicGraphDetector;
import hudson.util.CyclicGraphDetector.CycleDetectedException;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import hudson.util.MaskingClassLoader;
import hudson.util.VersionNumber;
......@@ -117,7 +116,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
try {
manifest = new Manifest(in);
} catch (IOException e) {
throw new IOException2("Failed to load " + archive, e);
throw new IOException("Failed to load " + archive, e);
} finally {
in.close();
}
......@@ -350,13 +349,13 @@ public class ClassicPluginStrategy implements PluginStrategy {
}
wrapper.setPlugin((Plugin) o);
} catch (LinkageError e) {
throw new IOException2("Unable to load " + className + " from " + wrapper.getShortName(),e);
throw new IOException("Unable to load " + className + " from " + wrapper.getShortName(),e);
} catch (ClassNotFoundException e) {
throw new IOException2("Unable to load " + className + " from " + wrapper.getShortName(),e);
throw new IOException("Unable to load " + className + " from " + wrapper.getShortName(),e);
} catch (IllegalAccessException e) {
throw new IOException2("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
throw new IOException("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
} catch (InstantiationException e) {
throw new IOException2("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
throw new IOException("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
}
}
......@@ -367,7 +366,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
startPlugin(wrapper);
} catch(Throwable t) {
// gracefully handle any error in plugin.
throw new IOException2("Failed to initialize",t);
throw new IOException("Failed to initialize",t);
}
} finally {
Thread.currentThread().setContextClassLoader(old);
......@@ -427,7 +426,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
unzipExceptClasses(archive, destDir, prj);
createClassJarFromWebInfClasses(archive, destDir, prj);
} catch (BuildException x) {
throw new IOException2("Failed to expand " + archive,x);
throw new IOException("Failed to expand " + archive,x);
}
try {
......
......@@ -43,7 +43,6 @@ import hudson.remoting.RemoteInputStream;
import hudson.remoting.Which;
import hudson.security.AccessControlled;
import hudson.util.DirScanner;
import hudson.util.IOException2;
import hudson.util.HeadBufferingStream;
import hudson.util.FormValidation;
import hudson.util.IOUtils;
......@@ -95,14 +94,12 @@ import java.util.concurrent.TimeoutException;
import com.jcraft.jzlib.GZIPInputStream;
import com.jcraft.jzlib.GZIPOutputStream;
import com.sun.jna.Native;
import hudson.os.PosixException;
import hudson.util.FileVisitor;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import org.apache.tools.ant.taskdefs.Chmod;
import org.apache.tools.zip.ZipFile;
import org.apache.tools.zip.ZipEntry;
......@@ -636,7 +633,7 @@ public final class FilePath implements Serializable {
} catch (IOException e) {
// various people reported "java.io.IOException: Not in GZIP format" here, so diagnose this problem better
in.fillSide();
throw new IOException2(e.getMessage()+"\nstream="+Util.toHexString(in.getSideBuffer()),e);
throw new IOException(e.getMessage()+"\nstream="+Util.toHexString(in.getSideBuffer()),e);
}
}
public OutputStream compress(OutputStream out) throws IOException {
......@@ -760,13 +757,13 @@ public final class FilePath implements Serializable {
else
untarFrom(cis,GZIP);
} catch (IOException e) {
throw new IOException2(String.format("Failed to unpack %s (%d bytes read of total %d)",
throw new IOException(String.format("Failed to unpack %s (%d bytes read of total %d)",
archive,cis.getByteCount(),con.getContentLength()),e);
}
timestamp.touch(sourceTimestamp);
return true;
} catch (IOException e) {
throw new IOException2("Failed to install "+archive+" to "+remote,e);
throw new IOException("Failed to install "+archive+" to "+remote,e);
}
}
......@@ -786,7 +783,7 @@ public final class FilePath implements Serializable {
readFromTar("input stream", dir, GZIP.extract(cis));
}
} catch (IOException x) {
throw new IOException2(String.format("Failed to unpack %s (%d bytes read)", archive, cis.getByteCount()), x);
throw new IOException(String.format("Failed to unpack %s (%d bytes read)", archive, cis.getByteCount()), x);
}
} finally {
in.close();
......@@ -843,7 +840,7 @@ public final class FilePath implements Serializable {
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException2(e);
throw new IOException(e);
}
} else {
InputStream i = file.getInputStream();
......@@ -910,7 +907,7 @@ public final class FilePath implements Serializable {
throw e; // pass through so that the caller can catch it as AbortException
} catch (IOException e) {
// wrap it into a new IOException so that we get the caller's stack trace as well.
throw new IOException2("remote file operation failed: "+remote+" at "+channel,e);
throw new IOException("remote file operation failed: "+remote+" at "+channel,e);
}
} else {
// the file is on the local machine.
......@@ -992,7 +989,7 @@ public final class FilePath implements Serializable {
.callAsync(wrapper);
} catch (IOException e) {
// wrap it into a new IOException so that we get the caller's stack trace as well.
throw new IOException2("remote file operation failed",e);
throw new IOException("remote file operation failed",e);
}
}
......@@ -1191,7 +1188,7 @@ public final class FilePath implements Serializable {
}
}));
} catch (IOException e) {
throw new IOException2("Failed to create a temp file on "+remote,e);
throw new IOException("Failed to create a temp file on "+remote,e);
}
}
......@@ -1251,7 +1248,7 @@ public final class FilePath implements Serializable {
try {
f = File.createTempFile(prefix, suffix, dir);
} catch (IOException e) {
throw new IOException2("Failed to create a temporary directory in "+dir,e);
throw new IOException("Failed to create a temporary directory in "+dir,e);
}
Writer w = new FileWriter(f);
......@@ -1265,7 +1262,7 @@ public final class FilePath implements Serializable {
}
}));
} catch (IOException e) {
throw new IOException2("Failed to create a temp file on "+remote,e);
throw new IOException("Failed to create a temp file on "+remote,e);
}
}
......@@ -1295,7 +1292,7 @@ public final class FilePath implements Serializable {
}
}));
} catch (IOException e) {
throw new IOException2("Failed to create a temp directory on "+remote,e);
throw new IOException("Failed to create a temp directory on "+remote,e);
}
}
......@@ -1749,7 +1746,7 @@ public final class FilePath implements Serializable {
out.close();
}
} catch (IOException e) {
throw new IOException2("Failed to copy "+this+" to "+target,e);
throw new IOException("Failed to copy "+this+" to "+target,e);
}
}
......@@ -1944,7 +1941,7 @@ public final class FilePath implements Serializable {
future.get();
return future2.get();
} catch (ExecutionException e) {
throw new IOException2(e);
throw new IOException(e);
}
} else {
// remote -> local copy
......@@ -1968,7 +1965,7 @@ public final class FilePath implements Serializable {
throw e; // the remote side completed successfully, so the error must be local
} catch (ExecutionException x) {
// report both errors
throw new IOException2(Functions.printThrowable(e),x);
throw new IOException(Functions.printThrowable(e),x);
} catch (TimeoutException _) {
// remote is hanging
throw e;
......@@ -1977,7 +1974,7 @@ public final class FilePath implements Serializable {
try {
return future.get();
} catch (ExecutionException e) {
throw new IOException2(e);
throw new IOException(e);
}
}
}
......@@ -2049,12 +2046,12 @@ public final class FilePath implements Serializable {
}
}
} catch(IOException e) {
throw new IOException2("Failed to extract "+name,e);
throw new IOException("Failed to extract "+name,e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // process this later
throw new IOException2("Failed to extract "+name,e);
throw new IOException("Failed to extract "+name,e);
} catch (IllegalAccessException e) {
throw new IOException2("Failed to extract "+name,e);
throw new IOException("Failed to extract "+name,e);
} finally {
t.close();
}
......@@ -2438,7 +2435,7 @@ public final class FilePath implements Serializable {
/**
* Used to tunnel {@link InterruptedException} over a Java signature that only allows {@link IOException}
*/
private static class TunneledInterruptedException extends IOException2 {
private static class TunneledInterruptedException extends IOException {
private TunneledInterruptedException(InterruptedException cause) {
super(cause);
}
......
......@@ -40,7 +40,6 @@ import hudson.security.Permission;
import hudson.security.PermissionScope;
import hudson.util.CyclicGraphDetector;
import hudson.util.CyclicGraphDetector.CycleDetectedException;
import hudson.util.IOException2;
import hudson.util.PersistedList;
import hudson.util.Service;
import hudson.util.VersionNumber;
......@@ -435,7 +434,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
failedPlugins.add(new FailedPlugin(sn, e));
activePlugins.remove(p);
plugins.remove(p);
throw new IOException2("Failed to install "+ sn +" plugin",e);
throw new IOException("Failed to install "+ sn +" plugin",e);
}
// run initializers in the added plugin
......@@ -449,7 +448,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
try {
new InitReactorRunner().run(r);
} catch (ReactorException e) {
throw new IOException2("Failed to initialize "+ sn +" plugin",e);
throw new IOException("Failed to initialize "+ sn +" plugin",e);
}
LOGGER.info("Plugin " + sn + " dynamically installed");
}
......@@ -925,7 +924,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
}
});
} catch (SAXException x) {
throw new IOException2("Failed to parse XML",x);
throw new IOException("Failed to parse XML",x);
} catch (ParserConfigurationException e) {
throw new AssertionError(e); // impossible since we don't tweak XMLParser
}
......
......@@ -28,7 +28,6 @@ import hudson.model.TaskListener;
import hudson.remoting.Channel;
import hudson.util.DaemonThreadFactory;
import hudson.util.ExceptionCatchingThreadFactory;
import hudson.util.IOException2;
import hudson.util.NullStream;
import hudson.util.StreamCopyThread;
import hudson.util.ProcessTree;
......@@ -454,7 +453,7 @@ public abstract class Proc {
} catch (ExecutionException e) {
if(e.getCause() instanceof IOException)
throw (IOException)e.getCause();
throw new IOException2("Failed to join the process",e);
throw new IOException("Failed to join the process",e);
} catch (CancellationException x) {
return -1;
}
......
......@@ -30,7 +30,6 @@ import edu.umd.cs.findbugs.annotations.SuppressWarnings;
import hudson.Proc.LocalProc;
import hudson.model.TaskListener;
import hudson.os.PosixAPI;
import hudson.util.IOException2;
import hudson.util.QuotedStringTokenizer;
import hudson.util.VariableResolver;
import hudson.util.jna.WinIOException;
......@@ -569,7 +568,7 @@ public class Util {
}
return toHexString(md5.digest());
} catch (NoSuchAlgorithmException e) {
throw new IOException2("MD5 not installed",e); // impossible
throw new IOException("MD5 not installed",e); // impossible
}
/* JENKINS-18178: confuses Maven 2 runner
try {
......
......@@ -32,7 +32,6 @@ import com.thoughtworks.xstream.io.xml.XppDriver;
import hudson.diagnosis.OldDataMonitor;
import hudson.model.Descriptor;
import hudson.util.AtomicFileWriter;
import hudson.util.IOException2;
import hudson.util.XStream2;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
......@@ -142,11 +141,11 @@ public final class XmlFile {
try {
return xs.fromXML(in);
} catch(StreamException e) {
throw new IOException2("Unable to read "+file,e);
throw new IOException("Unable to read "+file,e);
} catch(ConversionException e) {
throw new IOException2("Unable to read "+file,e);
throw new IOException("Unable to read "+file,e);
} catch(Error e) {// mostly reflection errors
throw new IOException2("Unable to read "+file,e);
throw new IOException("Unable to read "+file,e);
} finally {
in.close();
}
......@@ -165,11 +164,11 @@ public final class XmlFile {
// TODO: expose XStream the driver from XStream
return xs.unmarshal(DEFAULT_DRIVER.createReader(in), o);
} catch (StreamException e) {
throw new IOException2("Unable to read "+file,e);
throw new IOException("Unable to read "+file,e);
} catch(ConversionException e) {
throw new IOException2("Unable to read "+file,e);
throw new IOException("Unable to read "+file,e);
} catch(Error e) {// mostly reflection errors
throw new IOException2("Unable to read "+file,e);
throw new IOException("Unable to read "+file,e);
} finally {
in.close();
}
......@@ -183,7 +182,7 @@ public final class XmlFile {
xs.toXML(o,w);
w.commit();
} catch(StreamException e) {
throw new IOException2(e);
throw new IOException(e);
} finally {
w.abort();
}
......@@ -294,7 +293,7 @@ public final class XmlFile {
// in such a case, assume UTF-8 rather than fail, since Jenkins internally always write XML in UTF-8
return "UTF-8";
} catch (SAXException e) {
throw new IOException2("Failed to detect encoding of "+file,e);
throw new IOException("Failed to detect encoding of "+file,e);
} catch (ParserConfigurationException e) {
throw new AssertionError(e); // impossible
} finally {
......
......@@ -31,7 +31,6 @@ import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import hudson.util.IOException2;
import hudson.model.UnprotectedRootAction;
import jenkins.model.Jenkins;
......@@ -130,7 +129,7 @@ public class CLIAction implements UnprotectedRootAction, StaplerProxy {
duplexChannels.get(uuid).upload(req,rsp);
}
} catch (InterruptedException e) {
throw new IOException2(e);
throw new IOException(e);
}
}
}
......
package hudson.cli;
import hudson.Extension;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import javax.crypto.SecretKey;
......@@ -72,7 +71,7 @@ public class CliProtocol2 extends CliProtocol {
runCli(c);
} catch (GeneralSecurityException e) {
throw new IOException2("Failed to encrypt the CLI channel",e);
throw new IOException("Failed to encrypt the CLI channel",e);
}
}
}
......
......@@ -26,7 +26,6 @@ package hudson.cli;
import hudson.Extension;
import hudson.FilePath;
import hudson.PluginManager;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import hudson.model.UpdateSite;
import hudson.model.UpdateSite.Data;
......@@ -35,6 +34,7 @@ import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.HashSet;
......@@ -114,7 +114,7 @@ public class InstallPluginCommand extends CLICommand {
stdout.println(Messages.InstallPluginCommand_InstallingFromUpdateCenter(source));
Throwable e = p.deploy(dynamicLoad).get().getError();
if (e!=null)
throw new IOException2("Failed to install plugin "+source,e);
throw new IOException("Failed to install plugin "+source,e);
continue;
}
......
......@@ -28,8 +28,6 @@ package hudson.console;
import com.trilead.ssh2.crypto.Base64;
import jenkins.model.Jenkins;
import hudson.remoting.ObjectInputStreamEx;
import hudson.util.IOException2;
import hudson.util.Secret;
import hudson.util.TimeUnit2;
import jenkins.security.CryptoConfidentialKey;
import org.apache.commons.io.output.ByteArrayOutputStream;
......@@ -50,7 +48,6 @@ import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.charset.Charset;
import java.security.GeneralSecurityException;
import com.jcraft.jzlib.GZIPInputStream;
import com.jcraft.jzlib.GZIPOutputStream;
......@@ -134,7 +131,7 @@ public class AnnotatedLargeText<T> extends LargeText {
}
}
} catch (ClassNotFoundException e) {
throw new IOException2(e);
throw new IOException(e);
}
// start from scratch
return ConsoleAnnotator.initial(context==null ? null : context.getClass());
......
......@@ -30,7 +30,6 @@ import hudson.model.Describable;
import jenkins.model.Jenkins;
import hudson.model.Run;
import hudson.remoting.ObjectInputStreamEx;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import hudson.util.UnbufferedBase64InputStream;
import org.apache.commons.codec.binary.Base64OutputStream;
......@@ -228,7 +227,7 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
} catch (Error e) {
// for example, bogus 'sz' can result in OutOfMemoryError.
// package that up as IOException so that the caller won't fatally die.
throw new IOException2(e);
throw new IOException(e);
}
}
......
......@@ -660,7 +660,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
try {
l.onChangeLogParsed(build,listener,build.getChangeSet());
} catch (Exception e) {
throw new IOException2("Failed to parse changelog",e);
throw new IOException("Failed to parse changelog",e);
}
// Get a chance to do something after checkout and changelog is done
......
......@@ -40,7 +40,6 @@ import hudson.security.ACL;
import hudson.util.AlternativeUiTextProvider;
import hudson.util.AlternativeUiTextProvider.Message;
import hudson.util.AtomicFileWriter;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import jenkins.model.Jenkins;
import org.apache.tools.ant.taskdefs.Copy;
......@@ -586,7 +585,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
new StreamResult(out));
out.close();
} catch (TransformerException e) {
throw new IOException2("Failed to persist configuration.xml", e);
throw new IOException("Failed to persist configuration.xml", e);
}
// try to reflect the changes by reloading
......
......@@ -23,7 +23,6 @@
*/
package hudson.model;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import jenkins.security.SecureRequester;
......@@ -152,7 +151,7 @@ public class Api extends AbstractModelObject {
} catch (DocumentException e) {
LOGGER.log(Level.FINER, "Failed to do XPath/wrapper handling. XML is as follows:"+sw, e);
throw new IOException2("Failed to do XPath/wrapper handling. Turn on FINER logging to view XML.",e);
throw new IOException("Failed to do XPath/wrapper handling. Turn on FINER logging to view XML.",e);
}
OutputStream o = rsp.getCompressedOutputStream(req);
......
......@@ -25,7 +25,6 @@ package hudson.model;
import hudson.FilePath;
import hudson.Util;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -122,7 +121,7 @@ public final class DirectoryBrowserSupport implements HttpResponse {
try {
serveFile(req,rsp,base,icon,serveDirIndex);
} catch (InterruptedException e) {
throw new IOException2("interrupted",e);
throw new IOException("interrupted",e);
}
}
......
......@@ -28,7 +28,6 @@ import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.util.FormValidation;
import hudson.util.FormValidation.Kind;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import hudson.util.QuotedStringTokenizer;
import hudson.util.TextFile;
......@@ -240,7 +239,7 @@ public class DownloadService extends PageDecorator {
return JSONObject.fromObject(df.read());
} catch (JSONException e) {
df.delete(); // if we keep this file, it will cause repeated failures
throw new IOException2("Failed to parse "+df+" into JSON",e);
throw new IOException("Failed to parse "+df+" into JSON",e);
}
return null;
}
......
......@@ -34,7 +34,6 @@ import hudson.BulkChange;
import hudson.EnvVars;
import hudson.ExtensionPoint;
import hudson.FeedAdapter;
import hudson.FilePath;
import hudson.Util;
import hudson.XmlFile;
import hudson.cli.declarative.CLIMethod;
......@@ -55,7 +54,6 @@ import hudson.tasks.BuildWrapper;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.util.FlushProofOutputStream;
import hudson.util.FormApply;
import hudson.util.IOException2;
import hudson.util.LogTaskListener;
import hudson.util.XStream2;
......@@ -392,7 +390,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
} catch (ParseException e) {
throw new InvalidDirectoryNameException(buildDir);
} catch (InterruptedException e) {
throw new IOException2("Interrupted while resolving symlink directory "+buildDir,e);
throw new IOException("Interrupted while resolving symlink directory "+buildDir,e);
}
}
......
......@@ -44,7 +44,6 @@ import hudson.security.ACL;
import hudson.util.DaemonThreadFactory;
import hudson.util.FormValidation;
import hudson.util.HttpResponses;
import hudson.util.IOException2;
import hudson.util.PersistedList;
import hudson.util.XStream2;
import jenkins.RestartRequiredException;
......@@ -776,7 +775,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
job.status = job.new Installing(total==-1 ? -1 : in.getCount()*100/total);
}
} catch (IOException e) {
throw new IOException2("Failed to load "+src+" to "+tmp,e);
throw new IOException("Failed to load "+src+" to "+tmp,e);
}
in.close();
......@@ -791,7 +790,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
return tmp;
} catch (IOException e) {
throw new IOException2("Failed to download from "+src,e);
throw new IOException("Failed to download from "+src,e);
}
}
......@@ -873,7 +872,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
} catch (SSLHandshakeException e) {
if (e.getMessage().contains("PKIX path building failed"))
// fix up this crappy error message from JDK
throw new IOException2("Failed to validate the SSL certificate of "+url,e);
throw new IOException("Failed to validate the SSL certificate of "+url,e);
}
}
}
......@@ -1314,7 +1313,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
} catch (RestartRequiredException e) {
throw new SuccessButRequiresRestart(e.message);
} catch (Exception e) {
throw new IOException2("Failed to dynamically deploy this plugin",e);
throw new IOException("Failed to dynamically deploy this plugin",e);
}
} else {
throw new SuccessButRequiresRestart(Messages._UpdateCenter_DownloadButNotActivated());
......
......@@ -50,7 +50,6 @@ import hudson.util.AlternativeUiTextProvider.Message;
import hudson.util.DescribableList;
import hudson.util.DescriptorList;
import hudson.util.FormApply;
import hudson.util.IOException2;
import hudson.util.RunList;
import hudson.util.XStream2;
import hudson.views.ListViewColumn;
......@@ -1085,7 +1084,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
new StreamResult(out));
out.close();
} catch (TransformerException e) {
throw new IOException2("Failed to persist configuration.xml", e);
throw new IOException("Failed to persist configuration.xml", e);
}
// try to reflect the changes by reloading
......@@ -1097,11 +1096,11 @@ public abstract class View extends AbstractModelObject implements AccessControll
Jenkins.XSTREAM.unmarshal(new XppDriver().createReader(in), this);
name = oldname;
} catch (StreamException e) {
throw new IOException2("Unable to read",e);
throw new IOException("Unable to read",e);
} catch(ConversionException e) {
throw new IOException2("Unable to read",e);
throw new IOException("Unable to read",e);
} catch(Error e) {// mostly reflection errors
throw new IOException2("Unable to read",e);
throw new IOException("Unable to read",e);
} finally {
in.close();
}
......@@ -1210,11 +1209,11 @@ public abstract class View extends AbstractModelObject implements AccessControll
checkGoodName(v.name);
return v;
} catch(StreamException e) {
throw new IOException2("Unable to read",e);
throw new IOException("Unable to read",e);
} catch(ConversionException e) {
throw new IOException2("Unable to read",e);
throw new IOException("Unable to read",e);
} catch(Error e) {// mostly reflection errors
throw new IOException2("Unable to read",e);
throw new IOException("Unable to read",e);
} finally {
in.close();
}
......
......@@ -28,10 +28,6 @@ import hudson.Extension;
import hudson.slaves.OfflineCause;
import hudson.model.Computer;
import hudson.remoting.Callable;
import hudson.remoting.Future;
import hudson.util.ClockDifference;
import hudson.util.TimeUnit2;
import hudson.util.IOException2;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
......@@ -39,9 +35,6 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
......
......@@ -7,7 +7,6 @@ import hudson.Util;
import hudson.model.Computer;
import hudson.model.TaskListener;
import hudson.remoting.Channel;
import hudson.util.IOException2;
import hudson.util.StreamCopyThread;
import org.jinterop.dcom.common.JIException;
import org.jvnet.hudson.remcom.WindowsRemoteProcessLauncher;
......@@ -56,9 +55,9 @@ public class WindowsRemoteLauncher extends Launcher {
try {
proc = launcher.launch(buildCommandLine(ps), ps.pwd().getRemote());
} catch (JIException e) {
throw new IOException2(e);
throw new IOException(e);
} catch (InterruptedException e) {
throw new IOException2(e);
throw new IOException(e);
}
final Thread t1 = new StreamCopyThread("stdout copier: "+name, proc.getInputStream(), ps.stdout(),false);
t1.start();
......@@ -117,7 +116,7 @@ public class WindowsRemoteLauncher extends Launcher {
return new Channel("channel over named pipe to "+launcher.getHostName(),
Computer.threadPoolForRemoting, proc.getInputStream(), new BufferedOutputStream(proc.getOutputStream()));
} catch (JIException e) {
throw new IOException2(e);
throw new IOException(e);
}
}
......
......@@ -24,7 +24,6 @@
package hudson.slaves;
import hudson.model.*;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import hudson.util.io.ReopenableRotatingFileOutputStream;
import jenkins.model.Jenkins.MasterComputer;
......@@ -72,7 +71,6 @@ import javax.crypto.spec.SecretKeySpec;
import javax.servlet.RequestDispatcher;
import jenkins.model.Jenkins;
import jenkins.slaves.JnlpSlaveAgentProtocol;
import org.acegisecurity.Authentication;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.QueryParameter;
......@@ -613,7 +611,7 @@ public class SlaveComputer extends Computer {
c.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
encrypted = c.doFinal(baos.toByteArray());
} catch (GeneralSecurityException x) {
throw new IOException2(x);
throw new IOException(x);
}
res.setContentType("application/octet-stream");
res.getOutputStream().write(iv);
......
......@@ -47,7 +47,6 @@ import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import hudson.util.FormValidation;
import hudson.util.IOException2;
import hudson.util.PackedMap;
import hudson.util.RunList;
import net.sf.json.JSONObject;
......@@ -238,9 +237,9 @@ public class Fingerprinter extends Recorder implements Serializable, DependencyD
try {
results.add(new Record(produced,f,file.getName(),new FilePath(file).digest()));
} catch (IOException e) {
throw new IOException2(Messages.Fingerprinter_DigestFailed(file),e);
throw new IOException(Messages.Fingerprinter_DigestFailed(file),e);
} catch (InterruptedException e) {
throw new IOException2(Messages.Fingerprinter_Aborted(),e);
throw new IOException(Messages.Fingerprinter_Aborted(),e);
}
}
......
......@@ -24,9 +24,7 @@
package hudson.tasks.junit;
import hudson.tasks.test.TestObject;
import hudson.util.IOException2;
import hudson.util.io.ParserConfigurator;
import org.apache.commons.io.FileUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
......@@ -36,12 +34,7 @@ import org.kohsuke.stapler.export.ExportedBean;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
......@@ -212,7 +205,7 @@ public final class SuiteResult implements Serializable {
try {
stdout = CaseResult.possiblyTrimStdio(cases, keepLongStdio, mavenOutputFile);
} catch (IOException e) {
throw new IOException2("Failed to read "+mavenOutputFile,e);
throw new IOException("Failed to read "+mavenOutputFile,e);
}
}
}
......
......@@ -30,7 +30,6 @@ import hudson.model.Run;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.MetaTabulatedResult;
import hudson.tasks.test.TestObject;
import hudson.util.IOException2;
import java.io.File;
import java.io.IOException;
......@@ -274,12 +273,12 @@ public final class TestResult extends MetaTabulatedResult {
for (SuiteResult suiteResult : SuiteResult.parse(reportFile, keepLongStdio))
add(suiteResult);
} catch (InterruptedException e) {
throw new IOException2("Failed to read "+reportFile,e);
throw new IOException("Failed to read "+reportFile,e);
} catch (RuntimeException e) {
throw new IOException2("Failed to read "+reportFile,e);
throw new IOException("Failed to read "+reportFile,e);
} catch (DocumentException e) {
if (!reportFile.getPath().endsWith(".xml")) {
throw new IOException2("Failed to read "+reportFile+"\n"+
throw new IOException("Failed to read "+reportFile+"\n"+
"Is this really a JUnit report file? Your configuration must be matching too many files",e);
} else {
SuiteResult sr = new SuiteResult(reportFile.getName(), "", "");
......
......@@ -64,7 +64,7 @@ public class AtomicFileWriter extends Writer {
dir.mkdirs();
tmpFile = File.createTempFile("atomic",null, dir);
} catch (IOException e) {
throw new IOException2("Failed to create a temporary file in "+ dir,e);
throw new IOException("Failed to create a temporary file in "+ dir,e);
}
destFile = f;
if (encoding==null)
......
......@@ -29,21 +29,17 @@ import java.io.IOException;
* {@link IOException} with linked exception.
*
* @author Kohsuke Kawaguchi
* @deprecated Just use {@link IOException}, which since Java 6 supports a cause.
*/
@Deprecated
public class IOException2 extends IOException {
private final Throwable cause;
public IOException2(Throwable cause) {
super(cause.getMessage());
this.cause = cause;
super(cause);
}
public IOException2(String s, Throwable cause) {
super(s);
this.cause = cause;
super(s, cause);
}
public Throwable getCause() {
return cause;
}
}
......@@ -172,7 +172,7 @@ public final class RemotingDiagnostics {
return new FilePath(hprof);
} catch (JMException e) {
throw new IOException2(e);
throw new IOException(e);
}
}
......
......@@ -23,8 +23,6 @@
*/
package hudson.util.io;
import hudson.util.IOException2;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
......@@ -55,7 +53,7 @@ public class ReopenableFileOutputStream extends OutputStream {
try {
current = new FileOutputStream(out,appendOnNextOpen);
} catch (FileNotFoundException e) {
throw new IOException2("Failed to open "+out,e);
throw new IOException("Failed to open "+out,e);
}
return current;
}
......
......@@ -28,7 +28,6 @@ import hudson.Functions;
import hudson.org.apache.tools.tar.TarOutputStream;
import hudson.os.PosixException;
import hudson.util.FileVisitor;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import org.apache.tools.tar.TarEntry;
......@@ -80,7 +79,7 @@ final class TarArchiver extends Archiver {
linkName.setLength(0);
linkName.append(target);
} catch (IllegalAccessException x) {
throw new IOException2("Failed to set linkName", x);
throw new IOException("Failed to set linkName", x);
}
tar.putNextEntry(e);
......
......@@ -6,7 +6,6 @@ import com.trilead.ssh2.SFTPv3Client;
import com.trilead.ssh2.SFTPv3FileAttributes;
import com.trilead.ssh2.SFTPv3FileHandle;
import com.trilead.ssh2.sftp.ErrorCodes;
import hudson.util.IOException2;
import java.io.IOException;
import java.io.InputStream;
......@@ -62,7 +61,7 @@ public class SFTPClient extends SFTPv3Client {
try {
mkdir(path, posixPermission);
} catch (IOException e) {
throw new IOException2("Failed to mkdir "+path,e);
throw new IOException("Failed to mkdir "+path,e);
}
}
......
......@@ -25,7 +25,6 @@ package hudson.widgets;
import hudson.Util;
import hudson.model.Descriptor;
import hudson.util.IOException2;
import hudson.util.PackedMap;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyTagException;
......@@ -124,7 +123,7 @@ public class RenderOnDemandClosure {
}.invokeScript(req,rsp,bodyStack[0],null);
} catch (JellyTagException e) {
LOGGER.log(Level.WARNING, "Failed to evaluate the template closure", e);
throw new IOException2("Failed to evaluate the template closure",e);
throw new IOException("Failed to evaluate the template closure",e);
}
}
};
......
......@@ -2,7 +2,6 @@ package jenkins.security;
import hudson.FilePath;
import hudson.Util;
import hudson.util.IOException2;
import hudson.util.IOUtils;
import hudson.util.Secret;
import hudson.util.TextFile;
......@@ -80,7 +79,7 @@ public class DefaultConfidentialStore extends ConfidentialStore {
cos.write(payload);
cos.write(MAGIC);
} catch (GeneralSecurityException e) {
throw new IOException2("Failed to persist the key: "+key.getId(),e);
throw new IOException("Failed to persist the key: "+key.getId(),e);
} finally {
IOUtils.closeQuietly(cos);
IOUtils.closeQuietly(fos);
......@@ -107,7 +106,7 @@ public class DefaultConfidentialStore extends ConfidentialStore {
byte[] bytes = IOUtils.toByteArray(cis);
return verifyMagic(bytes);
} catch (GeneralSecurityException e) {
throw new IOException2("Failed to persist the key: "+key.getId(),e);
throw new IOException("Failed to persist the key: "+key.getId(),e);
} finally {
IOUtils.closeQuietly(cis);
IOUtils.closeQuietly(fis);
......
......@@ -6,7 +6,6 @@ import hudson.Util;
import hudson.remoting.Channel;
import hudson.remoting.Engine;
import hudson.slaves.SlaveComputer;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import java.io.ByteArrayInputStream;
......@@ -80,9 +79,9 @@ public class JnlpSlaveAgentProtocol2 extends JnlpSlaveAgentProtocol {
try {
computer.disconnect(new ConnectionFromCurrentPeer()).get(15, TimeUnit.SECONDS);
} catch (ExecutionException e) {
throw new IOException2("Failed to disconnect the current client",e);
throw new IOException("Failed to disconnect the current client",e);
} catch (TimeoutException e) {
throw new IOException2("Failed to disconnect the current client",e);
throw new IOException("Failed to disconnect the current client",e);
}
} else {
error(out, nodeName + " is already connected to this master. Rejecting this connection.");
......
new hudson.util.IOException2($t) :: $t instanceof Throwable => new java.io.IOException($t);;
new hudson.util.IOException2($s, $t) :: $s instanceof String && $t instanceof Throwable => new java.io.IOException($s, $t);;
......@@ -28,7 +28,6 @@ import hudson.FilePath.TarCompression;
import hudson.model.TaskListener;
import hudson.remoting.LocalChannel;
import hudson.remoting.VirtualChannel;
import hudson.util.IOException2;
import hudson.util.NullStream;
import java.io.ByteArrayInputStream;
......@@ -142,9 +141,9 @@ public class FilePathTest extends ChannelTestCase {
private Exception closed;
private volatile int count;
private void checkNotClosed() throws IOException2 {
private void checkNotClosed() throws IOException {
if (closed != null)
throw new IOException2(closed);
throw new IOException(closed);
}
@Override
......
......@@ -24,7 +24,6 @@
package org.jvnet.hudson.test;
import hudson.FilePath;
import hudson.util.IOException2;
import java.io.File;
import java.io.IOException;
......@@ -68,7 +67,7 @@ public class TemporaryDirectoryAllocator {
tmpDirectories.add(f);
return f;
} catch (IOException e) {
throw new IOException2("Failed to create a temporary directory in "+base,e);
throw new IOException("Failed to create a temporary directory in "+base,e);
}
}
......@@ -84,7 +83,7 @@ public class TemporaryDirectoryAllocator {
x = e;
}
tmpDirectories.clear();
if (x!=null) throw new IOException2("Failed to clean up temp dirs",x);
if (x!=null) throw new IOException("Failed to clean up temp dirs",x);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册