Index: DeployTask.java =================================================================== --- DeployTask.java (revision 908698) +++ DeployTask.java (working copy) @@ -137,7 +137,8 @@ * * @exception BuildException if an error occurs */ - public void execute() throws BuildException { + @Override + public void execute() throws BuildException { super.execute(); if (path == null) { @@ -166,8 +167,15 @@ } } else { try { - stream = new BufferedInputStream - (new FileInputStream(war), 1024); + FileInputStream fsInput = new FileInputStream(war); + long size = fsInput.getChannel().size(); + + if (size > Integer.MAX_VALUE) + throw new UnsupportedOperationException("DeployTask does not support WAR files greater than 2 Gb"); + contentLength = (int) size; + + stream = new BufferedInputStream(fsInput, 1024); + } catch (IOException e) { throw new BuildException(e); } Index: AbstractCatalinaTask.java =================================================================== --- AbstractCatalinaTask.java (revision 908698) +++ AbstractCatalinaTask.java (working copy) @@ -185,6 +185,8 @@ if (contentLength >= 0) { hconn.setRequestProperty("Content-Length", "" + contentLength); + + hconn.setFixedLengthStreamingMode(contentLength); } } else { hconn.setDoOutput(false);