Details
Description
When running unit tests in org.apache.oodt.cas.protocol.ftp.TestCogJGlobusFtpProtocol on a system that already has a service bound to TCP port 9000 on all interfaces, an error message appears:
testLSandCDandPWD(org.apache.oodt.cas.protocol.ftp.TestCogJGlobusFtpProtocol): Failed to bind to address 0.0.0.0/0.0.0.0:9000, check configuration
The stack trace is:
org.apache.ftpserver.FtpServerConfigurationException: Failed to bind to address 0.0.0.0/0.0.0.0:9000, check configuration at org.apache.ftpserver.listener.nio.NioListener.start(NioListener.java:181) at org.apache.ftpserver.impl.DefaultFtpServer.start(DefaultFtpServer.java:80) at org.apache.oodt.cas.protocol.ftp.TestCogJGlobusFtpProtocol.setUp(TestCogJGlobusFtpProtocol.java:78) at junit.framework.TestCase.runBare(TestCase.java:128) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:98) at org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:107) at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103) at $Proxy0.invoke(Unknown Source) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69) Caused by: java.net.BindException: Address already in use at sun.nio.ch.Net.bind(Native Method) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:251) at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:48) at org.apache.mina.core.polling.AbstractPollingIoAcceptor.registerHandles(AbstractPollingIoAcceptor.java:523) at org.apache.mina.core.polling.AbstractPollingIoAcceptor.access$200(AbstractPollingIoAcceptor.java:65) at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:407) at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619)
The offending code has a hard-coded port number:
public class TestCogJGlobusFtpProtocol extends TestCase { private static final int PORT = 9000; private FtpServer server; ...
On computers where a service is already bound to this port, the test case fails to set up its FTP server necessary for the test to run.
Using a system-assigned port, or trying incrementing port numbers up to a limit, would be better ways to avoid this issue.
Attachments
Issue Links
- is part of
-
OODT-644 Protocol tests are extremely buggy and unstable
- Closed