| @@ -625,8 +625,7 @@ public class Get extends Task { | |||||
| connection = openConnection(source); | connection = openConnection(source); | ||||
| if (connection == null) | |||||
| { | |||||
| if (connection == null) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -719,19 +718,14 @@ public class Get extends Task { | |||||
| if (connection instanceof HttpURLConnection) { | if (connection instanceof HttpURLConnection) { | ||||
| HttpURLConnection httpConnection = (HttpURLConnection) connection; | HttpURLConnection httpConnection = (HttpURLConnection) connection; | ||||
| int responseCode = httpConnection.getResponseCode(); | int responseCode = httpConnection.getResponseCode(); | ||||
| if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || | |||||
| responseCode == HttpURLConnection.HTTP_MOVED_TEMP || | |||||
| responseCode == HttpURLConnection.HTTP_SEE_OTHER || | |||||
| responseCode == HTTP_MOVED_TEMP) | |||||
| { | |||||
| if (isMoved(responseCode)) { | |||||
| String newLocation = httpConnection.getHeaderField("Location"); | String newLocation = httpConnection.getHeaderField("Location"); | ||||
| String message = aSource | String message = aSource | ||||
| + (responseCode == HttpURLConnection.HTTP_MOVED_PERM ? " permanently" | + (responseCode == HttpURLConnection.HTTP_MOVED_PERM ? " permanently" | ||||
| : "") + " moved to " + newLocation; | : "") + " moved to " + newLocation; | ||||
| log(message, logLevel); | log(message, logLevel); | ||||
| URL newURL = new URL(aSource, newLocation); | URL newURL = new URL(aSource, newLocation); | ||||
| if (!redirectionAllowed(aSource, newURL)) | |||||
| { | |||||
| if (!redirectionAllowed(aSource, newURL)) { | |||||
| return null; | return null; | ||||
| } | } | ||||
| return openConnection(newURL); | return openConnection(newURL); | ||||
| @@ -767,6 +761,13 @@ public class Get extends Task { | |||||
| return connection; | return connection; | ||||
| } | } | ||||
| private boolean isMoved(int responseCode) { | |||||
| return responseCode == HttpURLConnection.HTTP_MOVED_PERM || | |||||
| responseCode == HttpURLConnection.HTTP_MOVED_TEMP || | |||||
| responseCode == HttpURLConnection.HTTP_SEE_OTHER || | |||||
| responseCode == HTTP_MOVED_TEMP; | |||||
| } | |||||
| private boolean downloadFile() | private boolean downloadFile() | ||||
| throws FileNotFoundException, IOException { | throws FileNotFoundException, IOException { | ||||
| for (int i = 0; i < numberRetries; i++) { | for (int i = 0; i < numberRetries; i++) { | ||||
| @@ -120,8 +120,7 @@ public class HostInfo extends Task { | |||||
| while (interfaces.hasMoreElements()) { | while (interfaces.hasMoreElements()) { | ||||
| NetworkInterface currentif = interfaces.nextElement(); | NetworkInterface currentif = interfaces.nextElement(); | ||||
| Enumeration<InetAddress> addrs = currentif.getInetAddresses(); | Enumeration<InetAddress> addrs = currentif.getInetAddresses(); | ||||
| while (addrs.hasMoreElements()) | |||||
| { | |||||
| while (addrs.hasMoreElements()) { | |||||
| inetAddrs.add(addrs.nextElement()); | inetAddrs.add(addrs.nextElement()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -152,8 +151,7 @@ public class HostInfo extends Task { | |||||
| } | } | ||||
| } | } | ||||
| private boolean hasHostName(InetAddress addr) | |||||
| { | |||||
| private boolean hasHostName(InetAddress addr) { | |||||
| return !addr.getHostAddress().equals(addr.getCanonicalHostName()); | return !addr.getHostAddress().equals(addr.getCanonicalHostName()); | ||||
| } | } | ||||
| @@ -240,8 +238,7 @@ public class HostInfo extends Task { | |||||
| } | } | ||||
| } | } | ||||
| private void setDomainAndName(String fqdn) | |||||
| { | |||||
| private void setDomainAndName(String fqdn) { | |||||
| int idx = fqdn.indexOf('.'); | int idx = fqdn.indexOf('.'); | ||||
| if (idx > 0) { | if (idx > 0) { | ||||
| setProperty(NAME, fqdn.substring(0, idx)); | setProperty(NAME, fqdn.substring(0, idx)); | ||||
| @@ -323,6 +323,7 @@ public class SubAnt extends Task { | |||||
| ant = null; | ant = null; | ||||
| } | } | ||||
| } | } | ||||
| /** whether we should even try to continue after this error */ | /** whether we should even try to continue after this error */ | ||||
| private boolean isHardError(Throwable t) { | private boolean isHardError(Throwable t) { | ||||
| if (t instanceof BuildException) { | if (t instanceof BuildException) { | ||||
| @@ -175,16 +175,13 @@ public class CommandLauncher { | |||||
| try { | try { | ||||
| launcher = (CommandLauncher) Class.forName(launcherClass) | launcher = (CommandLauncher) Class.forName(launcherClass) | ||||
| .newInstance(); | .newInstance(); | ||||
| } | |||||
| catch(InstantiationException e) { | |||||
| } catch(InstantiationException e) { | |||||
| System.err.println("Could not instantiate launcher class " | System.err.println("Could not instantiate launcher class " | ||||
| + launcherClass + ": " + e.getMessage()); | + launcherClass + ": " + e.getMessage()); | ||||
| } | |||||
| catch(IllegalAccessException e) { | |||||
| } catch(IllegalAccessException e) { | |||||
| System.err.println("Could not instantiate launcher class " | System.err.println("Could not instantiate launcher class " | ||||
| + launcherClass + ": " + e.getMessage()); | + launcherClass + ": " + e.getMessage()); | ||||
| } | |||||
| catch(ClassNotFoundException e) { | |||||
| } catch(ClassNotFoundException e) { | |||||
| System.err.println("Could not instantiate launcher class " | System.err.println("Could not instantiate launcher class " | ||||
| + launcherClass + ": " + e.getMessage()); | + launcherClass + ": " + e.getMessage()); | ||||
| } | } | ||||
| @@ -56,8 +56,7 @@ public class MacCommandLauncher extends CommandLauncherProxy { | |||||
| System.getProperties().put("user.dir", workingDir.getAbsolutePath()); | System.getProperties().put("user.dir", workingDir.getAbsolutePath()); | ||||
| try { | try { | ||||
| return exec(project, cmd, env); | return exec(project, cmd, env); | ||||
| } | |||||
| finally { | |||||
| } finally { | |||||
| System.getProperties().put("user.dir", System.getProperty("user.dir")); | System.getProperties().put("user.dir", System.getProperty("user.dir")); | ||||
| } | } | ||||
| } | } | ||||
| @@ -742,9 +742,8 @@ public class NetRexxC extends MatchingTask { | |||||
| if (!compile && srcFile.lastModified() > javaFile.lastModified()) { | if (!compile && srcFile.lastModified() > javaFile.lastModified()) { | ||||
| filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); | filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); | ||||
| compileList.addElement(destFile.getAbsolutePath()); | compileList.addElement(destFile.getAbsolutePath()); | ||||
| } | |||||
| // compile case tests against .class file | |||||
| else if (compile && srcFile.lastModified() > classFile.lastModified()) { | |||||
| } else if (compile && srcFile.lastModified() > classFile.lastModified()) { | |||||
| // compile case tests against .class file | |||||
| filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); | filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); | ||||
| compileList.addElement(destFile.getAbsolutePath()); | compileList.addElement(destFile.getAbsolutePath()); | ||||
| } | } | ||||
| @@ -134,9 +134,9 @@ public class JUnitTask extends Task { | |||||
| = System.getProperty("line.separator"); | = System.getProperty("line.separator"); | ||||
| private static final String CLASSPATH = "CLASSPATH"; | private static final String CLASSPATH = "CLASSPATH"; | ||||
| private CommandlineJava commandline; | private CommandlineJava commandline; | ||||
| private Vector tests = new Vector(); | |||||
| private Vector batchTests = new Vector(); | |||||
| private Vector formatters = new Vector(); | |||||
| private Vector<JUnitTest> tests = new Vector<JUnitTest>(); | |||||
| private Vector<BatchTest> batchTests = new Vector<BatchTest>(); | |||||
| private Vector<FormatterElement> formatters = new Vector<FormatterElement>(); | |||||
| private File dir = null; | private File dir = null; | ||||
| private Integer timeout = null; | private Integer timeout = null; | ||||
| @@ -817,7 +817,7 @@ public class JUnitTask extends Task { | |||||
| setupJUnitDelegate(); | setupJUnitDelegate(); | ||||
| List testLists = new ArrayList(); | |||||
| List<List> testLists = new ArrayList<List>(); | |||||
| /* parallel test execution is only supported for multi-process execution */ | /* parallel test execution is only supported for multi-process execution */ | ||||
| int threads = ((!fork) || (forkMode.getValue().equals(ForkMode.ONCE)) | int threads = ((!fork) || (forkMode.getValue().equals(ForkMode.ONCE)) | ||||
| ? 1 | ? 1 | ||||
| @@ -830,7 +830,7 @@ public class JUnitTask extends Task { | |||||
| } else { /* forkMode.getValue().equals(ForkMode.PER_BATCH) */ | } else { /* forkMode.getValue().equals(ForkMode.PER_BATCH) */ | ||||
| final int count = batchTests.size(); | final int count = batchTests.size(); | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| BatchTest batchtest = (BatchTest) batchTests.elementAt(i); | |||||
| BatchTest batchtest = batchTests.elementAt(i); | |||||
| testLists.addAll(executeOrQueue(batchtest.elements(), false)); | testLists.addAll(executeOrQueue(batchtest.elements(), false)); | ||||
| } | } | ||||
| testLists.addAll(executeOrQueue(tests.elements(), forkPerTest)); | testLists.addAll(executeOrQueue(tests.elements(), forkPerTest)); | ||||
| @@ -860,7 +860,7 @@ public class JUnitTask extends Task { | |||||
| */ | */ | ||||
| private class JunitTestThread implements Runnable { | private class JunitTestThread implements Runnable { | ||||
| JunitTestThread(JUnitTask master, Iterator iterator, int id) { | |||||
| JunitTestThread(JUnitTask master, Iterator<List> iterator, int id) { | |||||
| this.masterTask = master; | this.masterTask = master; | ||||
| this.iterator = iterator; | this.iterator = iterator; | ||||
| this.id = id; | this.id = id; | ||||
| @@ -876,7 +876,7 @@ public class JUnitTask extends Task { | |||||
| } | } | ||||
| private JUnitTask masterTask; | private JUnitTask masterTask; | ||||
| private Iterator iterator; | |||||
| private Iterator<List> iterator; | |||||
| private int id; | private int id; | ||||
| } | } | ||||
| @@ -887,10 +887,10 @@ public class JUnitTask extends Task { | |||||
| * threads get the same test, or two threads simultaneously pop the list so that a test | * threads get the same test, or two threads simultaneously pop the list so that a test | ||||
| * gets skipped! | * gets skipped! | ||||
| */ | */ | ||||
| private List getNextTest(Iterator iter) { | |||||
| private List getNextTest(Iterator<List> iter) { | |||||
| synchronized(iter) { | synchronized(iter) { | ||||
| if (iter.hasNext()) { | if (iter.hasNext()) { | ||||
| return (List) iter.next(); | |||||
| return iter.next(); | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -907,7 +907,7 @@ public class JUnitTask extends Task { | |||||
| * fatal reason, no new tests/batches will be started but the running threads will be | * fatal reason, no new tests/batches will be started but the running threads will be | ||||
| * permitted to complete. Additional tests may start in already-running batch-test threads. | * permitted to complete. Additional tests may start in already-running batch-test threads. | ||||
| */ | */ | ||||
| private void oneJunitThread(Iterator iter, int threadId) { | |||||
| private void oneJunitThread(Iterator<List> iter, int threadId) { | |||||
| List l; | List l; | ||||
| log("Starting test thread " + threadId, Project.MSG_VERBOSE); | log("Starting test thread " + threadId, Project.MSG_VERBOSE); | ||||
| @@ -923,27 +923,26 @@ public class JUnitTask extends Task { | |||||
| } | } | ||||
| private void runTestsInThreads(List testList, int numThreads) { | |||||
| private void runTestsInThreads(List<List> testList, int numThreads) { | |||||
| Iterator iter = testList.iterator(); | |||||
| Iterator<List> iter = testList.iterator(); | |||||
| if (numThreads == 1) { | if (numThreads == 1) { | ||||
| /* with just one thread just run the test - don't create any threads */ | /* with just one thread just run the test - don't create any threads */ | ||||
| oneJunitThread(iter, 0); | oneJunitThread(iter, 0); | ||||
| } | |||||
| else { | |||||
| Thread threads[] = new Thread[numThreads]; | |||||
| } else { | |||||
| Thread[] threads = new Thread[numThreads]; | |||||
| int i; | int i; | ||||
| boolean exceptionOccurred; | boolean exceptionOccurred; | ||||
| /* Need to split apart tests, which are still grouped in batches */ | /* Need to split apart tests, which are still grouped in batches */ | ||||
| /* is there a simpler Java mechanism to do this? */ | /* is there a simpler Java mechanism to do this? */ | ||||
| /* I assume we don't want to do this with "per batch" forking. */ | /* I assume we don't want to do this with "per batch" forking. */ | ||||
| List newlist = new ArrayList(); | |||||
| List<List> newlist = new ArrayList<List>(); | |||||
| if (forkMode.getValue().equals(ForkMode.PER_TEST)) { | if (forkMode.getValue().equals(ForkMode.PER_TEST)) { | ||||
| Iterator i1 = testList.iterator(); | |||||
| Iterator<List> i1 = testList.iterator(); | |||||
| while (i1.hasNext()) { | while (i1.hasNext()) { | ||||
| List l = (List) i1.next(); | |||||
| List l = i1.next(); | |||||
| if (l.size() == 1) { | if (l.size() == 1) { | ||||
| newlist.add(l); | newlist.add(l); | ||||
| } else { | } else { | ||||
| @@ -974,8 +973,7 @@ public class JUnitTask extends Task { | |||||
| for (i = 0; i < numThreads; i++) { | for (i = 0; i < numThreads; i++) { | ||||
| threads[i].join(); | threads[i].join(); | ||||
| } | } | ||||
| } | |||||
| catch (InterruptedException e) { | |||||
| } catch (InterruptedException e) { | |||||
| exceptionOccurred = true; | exceptionOccurred = true; | ||||
| } | } | ||||
| } while (exceptionOccurred); | } while (exceptionOccurred); | ||||
| @@ -1656,11 +1654,11 @@ public class JUnitTask extends Task { | |||||
| * @return enumeration over individual tests | * @return enumeration over individual tests | ||||
| * @since Ant 1.3 | * @since Ant 1.3 | ||||
| */ | */ | ||||
| protected Enumeration getIndividualTests() { | |||||
| protected Enumeration<JUnitTest> getIndividualTests() { | |||||
| final int count = batchTests.size(); | final int count = batchTests.size(); | ||||
| final Enumeration[] enums = new Enumeration[ count + 1]; | final Enumeration[] enums = new Enumeration[ count + 1]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| BatchTest batchtest = (BatchTest) batchTests.elementAt(i); | |||||
| BatchTest batchtest = batchTests.elementAt(i); | |||||
| enums[i] = batchtest.elements(); | enums[i] = batchtest.elements(); | ||||
| } | } | ||||
| enums[enums.length - 1] = tests.elements(); | enums[enums.length - 1] = tests.elements(); | ||||
| @@ -1681,9 +1679,9 @@ public class JUnitTask extends Task { | |||||
| return; | return; | ||||
| } | } | ||||
| Enumeration testsEnum = tests.elements(); | |||||
| Enumeration<JUnitTest> testsEnum = tests.elements(); | |||||
| while (testsEnum.hasMoreElements()) { | while (testsEnum.hasMoreElements()) { | ||||
| JUnitTest test = (JUnitTest) testsEnum.nextElement(); | |||||
| JUnitTest test = testsEnum.nextElement(); | |||||
| if (test.hasMethodsSpecified() && test.shouldRun(getProject())) { | if (test.hasMethodsSpecified() && test.shouldRun(getProject())) { | ||||
| test.resolveMethods(); | test.resolveMethods(); | ||||
| } | } | ||||
| @@ -1695,7 +1693,7 @@ public class JUnitTask extends Task { | |||||
| * @return enumeration | * @return enumeration | ||||
| * @since Ant 1.3 | * @since Ant 1.3 | ||||
| */ | */ | ||||
| protected Enumeration allTests() { | |||||
| protected Enumeration<JUnitTest> allTests() { | |||||
| Enumeration[] enums = {tests.elements(), batchTests.elements()}; | Enumeration[] enums = {tests.elements(), batchTests.elements()}; | ||||
| return Enumerations.fromCompound(enums); | return Enumerations.fromCompound(enums); | ||||
| } | } | ||||
| @@ -1706,7 +1704,7 @@ public class JUnitTask extends Task { | |||||
| * @since Ant 1.3 | * @since Ant 1.3 | ||||
| */ | */ | ||||
| private FormatterElement[] mergeFormatters(JUnitTest test) { | private FormatterElement[] mergeFormatters(JUnitTest test) { | ||||
| Vector feVector = (Vector) formatters.clone(); | |||||
| Vector<FormatterElement> feVector = (Vector<FormatterElement>) formatters.clone(); | |||||
| test.addFormattersTo(feVector); | test.addFormattersTo(feVector); | ||||
| FormatterElement[] feArray = new FormatterElement[feVector.size()]; | FormatterElement[] feArray = new FormatterElement[feVector.size()]; | ||||
| feVector.copyInto(feArray); | feVector.copyInto(feArray); | ||||
| @@ -2083,11 +2081,11 @@ public class JUnitTask extends Task { | |||||
| * @return a list of tasks to be executed. | * @return a list of tasks to be executed. | ||||
| * @since 1.6.2 | * @since 1.6.2 | ||||
| */ | */ | ||||
| protected Collection executeOrQueue(Enumeration testList, | |||||
| protected Collection<List> executeOrQueue(Enumeration<JUnitTest> testList, | |||||
| boolean runIndividual) { | boolean runIndividual) { | ||||
| Map testConfigurations = new HashMap(); | |||||
| Map<ForkedTestConfiguration, List> testConfigurations = new HashMap<ForkedTestConfiguration, List>(); | |||||
| while (testList.hasMoreElements()) { | while (testList.hasMoreElements()) { | ||||
| JUnitTest test = (JUnitTest) testList.nextElement(); | |||||
| JUnitTest test = testList.nextElement(); | |||||
| if (test.shouldRun(getProject())) { | if (test.shouldRun(getProject())) { | ||||
| /* with multi-threaded runs need to defer execution of even */ | /* with multi-threaded runs need to defer execution of even */ | ||||
| /* individual tests so the threads can pick tests off the queue. */ | /* individual tests so the threads can pick tests off the queue. */ | ||||
| @@ -2096,9 +2094,9 @@ public class JUnitTask extends Task { | |||||
| } else { | } else { | ||||
| ForkedTestConfiguration c = | ForkedTestConfiguration c = | ||||
| new ForkedTestConfiguration(test); | new ForkedTestConfiguration(test); | ||||
| List l = (List) testConfigurations.get(c); | |||||
| List<JUnitTest> l = testConfigurations.get(c); | |||||
| if (l == null) { | if (l == null) { | ||||
| l = new ArrayList(); | |||||
| l = new ArrayList<JUnitTest>(); | |||||
| testConfigurations.put(c, l); | testConfigurations.put(c, l); | ||||
| } | } | ||||
| l.add(test); | l.add(test); | ||||
| @@ -90,6 +90,7 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
| testClass = Thread.currentThread().getContextClassLoader() | testClass = Thread.currentThread().getContextClassLoader() | ||||
| .loadClass(suiteName); | .loadClass(suiteName); | ||||
| } catch (ClassNotFoundException cnfe) { | } catch (ClassNotFoundException cnfe) { | ||||
| // ignore | |||||
| } | } | ||||
| } | } | ||||
| if (testClass == null && getClass().getClassLoader() != null) { | if (testClass == null && getClass().getClassLoader() != null) { | ||||
| @@ -97,6 +98,7 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
| testClass = | testClass = | ||||
| getClass().getClassLoader().loadClass(suiteName); | getClass().getClassLoader().loadClass(suiteName); | ||||
| } catch (ClassNotFoundException cnfe) { | } catch (ClassNotFoundException cnfe) { | ||||
| // ignore | |||||
| } | } | ||||
| } | } | ||||
| if (testClass == null) { | if (testClass == null) { | ||||
| @@ -168,6 +168,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
| hostname = localHost.getHostName(); | hostname = localHost.getHostName(); | ||||
| } | } | ||||
| } catch (UnknownHostException e) { | } catch (UnknownHostException e) { | ||||
| // fall back to default 'localhost' | |||||
| } | } | ||||
| return hostname; | return hostname; | ||||
| } | } | ||||
| @@ -256,8 +256,7 @@ public class SSHExec extends SSHBase { | |||||
| * If suppressSystemOut is <code>false</code>, normal behavior | * If suppressSystemOut is <code>false</code>, normal behavior | ||||
| * @since Ant 1.9.0 | * @since Ant 1.9.0 | ||||
| */ | */ | ||||
| public void setSuppressSystemOut(boolean suppressSystemOut) | |||||
| { | |||||
| public void setSuppressSystemOut(boolean suppressSystemOut) { | |||||
| this.suppressSystemOut = suppressSystemOut; | this.suppressSystemOut = suppressSystemOut; | ||||
| } | } | ||||
| @@ -266,8 +265,7 @@ public class SSHExec extends SSHBase { | |||||
| * If suppressSystemErr is <code>false</code>, normal behavior | * If suppressSystemErr is <code>false</code>, normal behavior | ||||
| * @since Ant 1.9.4 | * @since Ant 1.9.4 | ||||
| */ | */ | ||||
| public void setSuppressSystemErr(boolean suppressSystemErr) | |||||
| { | |||||
| public void setSuppressSystemErr(boolean suppressSystemErr) { | |||||
| this.suppressSystemErr = suppressSystemErr; | this.suppressSystemErr = suppressSystemErr; | ||||
| } | } | ||||
| @@ -225,27 +225,31 @@ public class SSHSession extends SSHBase { | |||||
| int rport = 0; | int rport = 0; | ||||
| public void setLPort(int lport) { | public void setLPort(int lport) { | ||||
| Integer portKey = new Integer(lport); | Integer portKey = new Integer(lport); | ||||
| if (localPortsUsed.contains(portKey)) | |||||
| if (localPortsUsed.contains(portKey)) { | |||||
| throw new BuildException("Multiple local tunnels defined to" | throw new BuildException("Multiple local tunnels defined to" | ||||
| + " use same local port " + lport); | + " use same local port " + lport); | ||||
| } | |||||
| localPortsUsed.add(portKey); | localPortsUsed.add(portKey); | ||||
| this.lport = lport; | this.lport = lport; | ||||
| } | } | ||||
| public void setRHost(String rhost) { this.rhost = rhost; } | public void setRHost(String rhost) { this.rhost = rhost; } | ||||
| public void setRPort(int rport) { this.rport = rport; } | public void setRPort(int rport) { this.rport = rport; } | ||||
| public int getLPort() { | public int getLPort() { | ||||
| if (lport == 0) throw new BuildException("lport is required for" | |||||
| + " LocalTunnel."); | |||||
| if (lport == 0) { | |||||
| throw new BuildException("lport is required for LocalTunnel."); | |||||
| } | |||||
| return lport; | return lport; | ||||
| } | } | ||||
| public String getRHost() { | public String getRHost() { | ||||
| if (rhost == null) throw new BuildException("rhost is required" | |||||
| + " for LocalTunnel."); | |||||
| if (rhost == null) { | |||||
| throw new BuildException("rhost is required for LocalTunnel."); | |||||
| } | |||||
| return rhost; | return rhost; | ||||
| } | } | ||||
| public int getRPort() { | public int getRPort() { | ||||
| if (rport == 0) throw new BuildException("rport is required for" | |||||
| + " LocalTunnel."); | |||||
| if (rport == 0) { | |||||
| throw new BuildException("rport is required for LocalTunnel."); | |||||
| } | |||||
| return rport; | return rport; | ||||
| } | } | ||||
| } | } | ||||
| @@ -260,25 +264,29 @@ public class SSHSession extends SSHBase { | |||||
| public void setLHost(String lhost) { this.lhost = lhost; } | public void setLHost(String lhost) { this.lhost = lhost; } | ||||
| public void setRPort(int rport) { | public void setRPort(int rport) { | ||||
| Integer portKey = new Integer(rport); | Integer portKey = new Integer(rport); | ||||
| if (remotePortsUsed.contains(portKey)) | |||||
| throw new BuildException("Multiple remote tunnels defined to" | |||||
| + " use same remote port " + rport); | |||||
| if (remotePortsUsed.contains(portKey)) { | |||||
| throw new BuildException("Multiple remote tunnels defined to" | |||||
| + " use same remote port " + rport); | |||||
| } | |||||
| remotePortsUsed.add(portKey); | remotePortsUsed.add(portKey); | ||||
| this.rport = rport; | this.rport = rport; | ||||
| } | } | ||||
| public int getLPort() { | public int getLPort() { | ||||
| if (lport == 0) throw new BuildException("lport is required for" | |||||
| + " RemoteTunnel."); | |||||
| if (lport == 0) { | |||||
| throw new BuildException("lport is required for RemoteTunnel."); | |||||
| } | |||||
| return lport; | return lport; | ||||
| } | } | ||||
| public String getLHost() { | public String getLHost() { | ||||
| if (lhost == null) throw new BuildException("lhost is required for" | |||||
| + " RemoteTunnel."); | |||||
| if (lhost == null) { | |||||
| throw new BuildException("lhost is required for RemoteTunnel."); | |||||
| } | |||||
| return lhost; | return lhost; | ||||
| } | } | ||||
| public int getRPort() { | public int getRPort() { | ||||
| if (rport == 0) throw new BuildException("rport is required for" | |||||
| + " RemoteTunnel."); | |||||
| if (rport == 0) { | |||||
| throw new BuildException("rport is required for RemoteTunnel."); | |||||
| } | |||||
| return rport; | return rport; | ||||
| } | } | ||||
| } | } | ||||
| @@ -301,7 +309,7 @@ public class SSHSession extends SSHBase { | |||||
| * This is a simple task container. | * This is a simple task container. | ||||
| */ | */ | ||||
| public static class NestedSequential implements TaskContainer { | public static class NestedSequential implements TaskContainer { | ||||
| private List nested = new ArrayList(); | |||||
| private List<Task> nested = new ArrayList<Task>(); | |||||
| /** | /** | ||||
| * Add a task or type to the container. | * Add a task or type to the container. | ||||
| @@ -315,7 +323,7 @@ public class SSHSession extends SSHBase { | |||||
| /** | /** | ||||
| * @return the list of unknown elements | * @return the list of unknown elements | ||||
| */ | */ | ||||
| public List getNested() { | |||||
| public List<Task> getNested() { | |||||
| return nested; | return nested; | ||||
| } | } | ||||
| } | } | ||||
| @@ -231,11 +231,9 @@ public class LayoutPreservingProperties extends Properties { | |||||
| LogicalLine line = (LogicalLine) i.next(); | LogicalLine line = (LogicalLine) i.next(); | ||||
| if (line instanceof Blank) { | if (line instanceof Blank) { | ||||
| out.println("blank: \"" + line + "\""); | out.println("blank: \"" + line + "\""); | ||||
| } | |||||
| else if (line instanceof Comment) { | |||||
| } else if (line instanceof Comment) { | |||||
| out.println("comment: \"" + line + "\""); | out.println("comment: \"" + line + "\""); | ||||
| } | |||||
| else if (line instanceof Pair) { | |||||
| } else if (line instanceof Pair) { | |||||
| out.println("pair: \"" + line + "\""); | out.println("pair: \"" + line + "\""); | ||||
| } | } | ||||
| } | } | ||||
| @@ -294,8 +292,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
| } | } | ||||
| } | } | ||||
| osw.write(line.toString() + LS); | osw.write(line.toString() + LS); | ||||
| } | |||||
| else if (line != null) { | |||||
| } else if (line != null) { | |||||
| osw.write(line.toString() + LS); | osw.write(line.toString() + LS); | ||||
| } | } | ||||
| } | } | ||||
| @@ -456,28 +453,26 @@ public class LayoutPreservingProperties extends Properties { | |||||
| if (c == '\n') { | if (c == '\n') { | ||||
| // we have hit out end-of-string marker | // we have hit out end-of-string marker | ||||
| break; | break; | ||||
| } | |||||
| else if (c == '\\') { | |||||
| } else if (c == '\\') { | |||||
| // possibly an escape sequence | // possibly an escape sequence | ||||
| c = ch[++i]; | c = ch[++i]; | ||||
| if (c == 'n') | |||||
| if (c == 'n') { | |||||
| buffy.append('\n'); | buffy.append('\n'); | ||||
| else if (c == 'r') | |||||
| } else if (c == 'r') { | |||||
| buffy.append('\r'); | buffy.append('\r'); | ||||
| else if (c == 'f') | |||||
| } else if (c == 'f') { | |||||
| buffy.append('\f'); | buffy.append('\f'); | ||||
| else if (c == 't') | |||||
| } else if (c == 't') { | |||||
| buffy.append('\t'); | buffy.append('\t'); | ||||
| else if (c == 'u') { | |||||
| } else if (c == 'u') { | |||||
| // handle unicode escapes | // handle unicode escapes | ||||
| c = unescapeUnicode(ch, i+1); | c = unescapeUnicode(ch, i+1); | ||||
| i += 4; | i += 4; | ||||
| buffy.append(c); | buffy.append(c); | ||||
| } | |||||
| else | |||||
| } else { | |||||
| buffy.append(c); | buffy.append(c); | ||||
| } | |||||
| else { | |||||
| } | |||||
| } else { | |||||
| buffy.append(c); | buffy.append(c); | ||||
| } | } | ||||
| } | } | ||||
| @@ -694,8 +689,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
| Object dolly = null; | Object dolly = null; | ||||
| try { | try { | ||||
| dolly = super.clone(); | dolly = super.clone(); | ||||
| } | |||||
| catch (CloneNotSupportedException e) { | |||||
| } catch (CloneNotSupportedException e) { | |||||
| // should be fine | // should be fine | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| @@ -709,8 +703,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
| // trim leading whitespace only | // trim leading whitespace only | ||||
| name = text; | name = text; | ||||
| value = null; | value = null; | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| name = text.substring(0, pos); | name = text.substring(0, pos); | ||||
| value = text.substring(pos+1, text.length()); | value = text.substring(pos+1, text.length()); | ||||
| } | } | ||||
| @@ -24,7 +24,8 @@ import java.lang.management.ManagementFactory; | |||||
| * @since Ant 1.9.4 | * @since Ant 1.9.4 | ||||
| */ | */ | ||||
| public class ProcessUtil { | public class ProcessUtil { | ||||
| /** | |||||
| /** | |||||
| * provide id of the current process | * provide id of the current process | ||||
| * @param fallback | * @param fallback | ||||
| * @return current process id | * @return current process id | ||||
| @@ -49,10 +50,13 @@ public class ProcessUtil { | |||||
| } | } | ||||
| return fallback; | return fallback; | ||||
| } | } | ||||
| public static void main(String [] args) { | public static void main(String [] args) { | ||||
| System.out.println(getProcessId("<PID>")); | System.out.println(getProcessId("<PID>")); | ||||
| try { | try { | ||||
| Thread.sleep(120000); | |||||
| } catch (Exception exc) {} | |||||
| Thread.sleep(120000); | |||||
| } catch (Exception exc) { | |||||
| // ignore | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -84,7 +84,7 @@ import org.apache.tools.zip.ZipEncoding; | |||||
| * field is the binary representation of the number. | * field is the binary representation of the number. | ||||
| * See TarUtils.parseOctalOrBinary. | * See TarUtils.parseOctalOrBinary. | ||||
| * </pre> | * </pre> | ||||
| * | |||||
| * | |||||
| * <p> | * <p> | ||||
| * The C structure for a old GNU Tar Entry's header is: | * The C structure for a old GNU Tar Entry's header is: | ||||
| * <pre> | * <pre> | ||||
| @@ -316,6 +316,7 @@ public class TarEntry implements TarConstants { | |||||
| * @param headerBuf The header bytes from a tar archive entry. | * @param headerBuf The header bytes from a tar archive entry. | ||||
| * @param encoding encoding to use for file names | * @param encoding encoding to use for file names | ||||
| * @throws IllegalArgumentException if any of the numeric fields have an invalid format | * @throws IllegalArgumentException if any of the numeric fields have an invalid format | ||||
| * @throws IOException if an error occurs during reading the archive | |||||
| */ | */ | ||||
| public TarEntry(byte[] headerBuf, ZipEncoding encoding) | public TarEntry(byte[] headerBuf, ZipEncoding encoding) | ||||
| throws IOException { | throws IOException { | ||||
| @@ -409,7 +410,7 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Set this entry's link name. | * Set this entry's link name. | ||||
| * | |||||
| * | |||||
| * @param link the link name to use. | * @param link the link name to use. | ||||
| */ | */ | ||||
| public void setLinkName(String link) { | public void setLinkName(String link) { | ||||
| @@ -572,8 +573,8 @@ public class TarEntry implements TarConstants { | |||||
| * @throws IllegalArgumentException if the size is < 0. | * @throws IllegalArgumentException if the size is < 0. | ||||
| */ | */ | ||||
| public void setSize(long size) { | public void setSize(long size) { | ||||
| if (size < 0){ | |||||
| throw new IllegalArgumentException("Size is out of range: "+size); | |||||
| if (size < 0) { | |||||
| throw new IllegalArgumentException("Size is out of range: " + size); | |||||
| } | } | ||||
| this.size = size; | this.size = size; | ||||
| } | } | ||||
| @@ -594,7 +595,7 @@ public class TarEntry implements TarConstants { | |||||
| * @throws IllegalArgumentException if the devNo is < 0. | * @throws IllegalArgumentException if the devNo is < 0. | ||||
| */ | */ | ||||
| public void setDevMajor(int devNo) { | public void setDevMajor(int devNo) { | ||||
| if (devNo < 0){ | |||||
| if (devNo < 0) { | |||||
| throw new IllegalArgumentException("Major device number is out of " | throw new IllegalArgumentException("Major device number is out of " | ||||
| + "range: " + devNo); | + "range: " + devNo); | ||||
| } | } | ||||
| @@ -617,7 +618,7 @@ public class TarEntry implements TarConstants { | |||||
| * @throws IllegalArgumentException if the devNo is < 0. | * @throws IllegalArgumentException if the devNo is < 0. | ||||
| */ | */ | ||||
| public void setDevMinor(int devNo) { | public void setDevMinor(int devNo) { | ||||
| if (devNo < 0){ | |||||
| if (devNo < 0) { | |||||
| throw new IllegalArgumentException("Minor device number is out of " | throw new IllegalArgumentException("Minor device number is out of " | ||||
| + "range: " + devNo); | + "range: " + devNo); | ||||
| } | } | ||||
| @@ -644,7 +645,7 @@ public class TarEntry implements TarConstants { | |||||
| } | } | ||||
| /** | /** | ||||
| * Indicate if this entry is a GNU sparse block | |||||
| * Indicate if this entry is a GNU sparse block. | |||||
| * | * | ||||
| * @return true if this is a sparse extension provided by GNU tar | * @return true if this is a sparse extension provided by GNU tar | ||||
| */ | */ | ||||
| @@ -674,20 +675,20 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Check if this is a Pax header. | * Check if this is a Pax header. | ||||
| * | |||||
| * | |||||
| * @return {@code true} if this is a Pax header. | * @return {@code true} if this is a Pax header. | ||||
| */ | */ | ||||
| public boolean isPaxHeader(){ | |||||
| public boolean isPaxHeader() { | |||||
| return linkFlag == LF_PAX_EXTENDED_HEADER_LC | return linkFlag == LF_PAX_EXTENDED_HEADER_LC | ||||
| || linkFlag == LF_PAX_EXTENDED_HEADER_UC; | || linkFlag == LF_PAX_EXTENDED_HEADER_UC; | ||||
| } | } | ||||
| /** | /** | ||||
| * Check if this is a Pax header. | * Check if this is a Pax header. | ||||
| * | |||||
| * | |||||
| * @return {@code true} if this is a Pax header. | * @return {@code true} if this is a Pax header. | ||||
| */ | */ | ||||
| public boolean isGlobalPaxHeader(){ | |||||
| public boolean isGlobalPaxHeader() { | |||||
| return linkFlag == LF_PAX_GLOBAL_EXTENDED_HEADER; | return linkFlag == LF_PAX_GLOBAL_EXTENDED_HEADER; | ||||
| } | } | ||||
| @@ -713,7 +714,8 @@ public class TarEntry implements TarConstants { | |||||
| } | } | ||||
| /** | /** | ||||
| * Check if this is a "normal file" | |||||
| * Check if this is a "normal file". | |||||
| * @return <i>true</i> if it is a 'normal' file | |||||
| */ | */ | ||||
| public boolean isFile() { | public boolean isFile() { | ||||
| if (file != null) { | if (file != null) { | ||||
| @@ -727,6 +729,7 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Check if this is a symbolic link entry. | * Check if this is a symbolic link entry. | ||||
| * @return <i>true</i> if it is a symlink | |||||
| */ | */ | ||||
| public boolean isSymbolicLink() { | public boolean isSymbolicLink() { | ||||
| return linkFlag == LF_SYMLINK; | return linkFlag == LF_SYMLINK; | ||||
| @@ -734,6 +737,7 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Check if this is a link entry. | * Check if this is a link entry. | ||||
| * @return <i>true</i> if it is a link | |||||
| */ | */ | ||||
| public boolean isLink() { | public boolean isLink() { | ||||
| return linkFlag == LF_LINK; | return linkFlag == LF_LINK; | ||||
| @@ -741,20 +745,21 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Check if this is a character device entry. | * Check if this is a character device entry. | ||||
| * @return <i>true</i> if it is a character device entry | |||||
| */ | */ | ||||
| public boolean isCharacterDevice() { | public boolean isCharacterDevice() { | ||||
| return linkFlag == LF_CHR; | return linkFlag == LF_CHR; | ||||
| } | } | ||||
| /** | /** | ||||
| * Check if this is a block device entry. | |||||
| * @return <i>true</i> if this is a block device entry. | |||||
| */ | */ | ||||
| public boolean isBlockDevice() { | public boolean isBlockDevice() { | ||||
| return linkFlag == LF_BLK; | return linkFlag == LF_BLK; | ||||
| } | } | ||||
| /** | /** | ||||
| * Check if this is a FIFO (pipe) entry. | |||||
| * @return <i>true</i> if this is a FIFO (pipe) entry. | |||||
| */ | */ | ||||
| public boolean isFIFO() { | public boolean isFIFO() { | ||||
| return linkFlag == LF_FIFO; | return linkFlag == LF_FIFO; | ||||
| @@ -809,6 +814,7 @@ public class TarEntry implements TarConstants { | |||||
| * @param starMode whether to use the star/GNU tar/BSD tar | * @param starMode whether to use the star/GNU tar/BSD tar | ||||
| * extension for numeric fields if their value doesn't fit in the | * extension for numeric fields if their value doesn't fit in the | ||||
| * maximum size of standard tar archives | * maximum size of standard tar archives | ||||
| * @throws IOException if an error occurs while writing the archive | |||||
| */ | */ | ||||
| public void writeEntryHeader(byte[] outbuf, ZipEncoding encoding, | public void writeEntryHeader(byte[] outbuf, ZipEncoding encoding, | ||||
| boolean starMode) throws IOException { | boolean starMode) throws IOException { | ||||
| @@ -857,7 +863,7 @@ public class TarEntry implements TarConstants { | |||||
| private int writeEntryHeaderField(long value, byte[] outbuf, int offset, | private int writeEntryHeaderField(long value, byte[] outbuf, int offset, | ||||
| int length, boolean starMode) { | int length, boolean starMode) { | ||||
| if (!starMode && (value < 0 | if (!starMode && (value < 0 | ||||
| || value >= (1l << (3 * (length - 1))))) { | |||||
| || value >= (1L << (3 * (length - 1))))) { | |||||
| // value doesn't fit into field when written as octal | // value doesn't fit into field when written as octal | ||||
| // number, will be written to PAX header or causes an | // number, will be written to PAX header or causes an | ||||
| // error | // error | ||||
| @@ -893,6 +899,7 @@ public class TarEntry implements TarConstants { | |||||
| * @param encoding encoding to use for file names | * @param encoding encoding to use for file names | ||||
| * @throws IllegalArgumentException if any of the numeric fields | * @throws IllegalArgumentException if any of the numeric fields | ||||
| * have an invalid format | * have an invalid format | ||||
| * @throws IOException if an error occurs while reading the archive | |||||
| */ | */ | ||||
| public void parseTarHeader(byte[] header, ZipEncoding encoding) | public void parseTarHeader(byte[] header, ZipEncoding encoding) | ||||
| throws IOException { | throws IOException { | ||||
| @@ -905,7 +912,7 @@ public class TarEntry implements TarConstants { | |||||
| int offset = 0; | int offset = 0; | ||||
| name = oldStyle ? TarUtils.parseName(header, offset, NAMELEN) | name = oldStyle ? TarUtils.parseName(header, offset, NAMELEN) | ||||
| : TarUtils.parseName(header, offset, NAMELEN, encoding); | |||||
| : TarUtils.parseName(header, offset, NAMELEN, encoding); | |||||
| offset += NAMELEN; | offset += NAMELEN; | ||||
| mode = (int) TarUtils.parseOctalOrBinary(header, offset, MODELEN); | mode = (int) TarUtils.parseOctalOrBinary(header, offset, MODELEN); | ||||
| offset += MODELEN; | offset += MODELEN; | ||||
| @@ -959,10 +966,10 @@ public class TarEntry implements TarConstants { | |||||
| : TarUtils.parseName(header, offset, PREFIXLEN, encoding); | : TarUtils.parseName(header, offset, PREFIXLEN, encoding); | ||||
| // SunOS tar -E does not add / to directory names, so fix | // SunOS tar -E does not add / to directory names, so fix | ||||
| // up to be consistent | // up to be consistent | ||||
| if (isDirectory() && !name.endsWith("/")){ | |||||
| if (isDirectory() && !name.endsWith("/")) { | |||||
| name = name + "/"; | name = name + "/"; | ||||
| } | } | ||||
| if (prefix.length() > 0){ | |||||
| if (prefix.length() > 0) { | |||||
| name = prefix + "/" + name; | name = prefix + "/" + name; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1030,7 +1037,7 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Check if buffer contents matches Ascii String. | * Check if buffer contents matches Ascii String. | ||||
| * | |||||
| * | |||||
| * @param expected | * @param expected | ||||
| * @param buffer | * @param buffer | ||||
| * @param offset | * @param offset | ||||
| @@ -1038,7 +1045,7 @@ public class TarEntry implements TarConstants { | |||||
| * @return {@code true} if buffer is the same as the expected string | * @return {@code true} if buffer is the same as the expected string | ||||
| */ | */ | ||||
| private static boolean matchAsciiBuffer(String expected, byte[] buffer, | private static boolean matchAsciiBuffer(String expected, byte[] buffer, | ||||
| int offset, int length){ | |||||
| int offset, int length) { | |||||
| byte[] buffer1; | byte[] buffer1; | ||||
| try { | try { | ||||
| buffer1 = expected.getBytes("ASCII"); | buffer1 = expected.getBytes("ASCII"); | ||||
| @@ -1051,7 +1058,7 @@ public class TarEntry implements TarConstants { | |||||
| /** | /** | ||||
| * Compare byte buffers, optionally ignoring trailing nulls | * Compare byte buffers, optionally ignoring trailing nulls | ||||
| * | |||||
| * | |||||
| * @param buffer1 | * @param buffer1 | ||||
| * @param offset1 | * @param offset1 | ||||
| * @param length1 | * @param length1 | ||||
| @@ -1064,26 +1071,26 @@ public class TarEntry implements TarConstants { | |||||
| private static boolean isEqual( | private static boolean isEqual( | ||||
| final byte[] buffer1, final int offset1, final int length1, | final byte[] buffer1, final int offset1, final int length1, | ||||
| final byte[] buffer2, final int offset2, final int length2, | final byte[] buffer2, final int offset2, final int length2, | ||||
| boolean ignoreTrailingNulls){ | |||||
| boolean ignoreTrailingNulls) { | |||||
| int minLen=length1 < length2 ? length1 : length2; | int minLen=length1 < length2 ? length1 : length2; | ||||
| for (int i=0; i < minLen; i++){ | |||||
| if (buffer1[offset1+i] != buffer2[offset2+i]){ | |||||
| for (int i=0; i < minLen; i++) { | |||||
| if (buffer1[offset1+i] != buffer2[offset2+i]) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| if (length1 == length2){ | |||||
| if (length1 == length2) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| if (ignoreTrailingNulls){ | |||||
| if (ignoreTrailingNulls) { | |||||
| if (length1 > length2){ | if (length1 > length2){ | ||||
| for(int i = length2; i < length1; i++){ | for(int i = length2; i < length1; i++){ | ||||
| if (buffer1[offset1+i] != 0){ | |||||
| if (buffer1[offset1+i] != 0) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| for(int i = length1; i < length2; i++){ | |||||
| if (buffer2[offset2+i] != 0){ | |||||
| for (int i = length1; i < length2; i++){ | |||||
| if (buffer2[offset2+i] != 0) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||