Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvn clean install fails on error in testcase #1

Closed
kwo opened this issue Aug 22, 2012 · 18 comments
Closed

mvn clean install fails on error in testcase #1

kwo opened this issue Aug 22, 2012 · 18 comments

Comments

@kwo
Copy link

kwo commented Aug 22, 2012

Cannot compile without deactivating the test cases. Error is follows

[ERROR] .../jeromq/src/test/java/zmq/Helper.java:[25,18] error: DummySocketChannel is not abstract and does not override abstract method getRemoteAddress() in SocketChannel

@miniway
Copy link
Member

miniway commented Aug 22, 2012

what is your java version? I tested with jdk1.6.0_33 and I didn't got the error.

@michaelklishin
Copy link

mvn test fails on JDK 7 (Oracle JDK 7u6 in my case). mvn compile succeeds.

@kwo
Copy link
Author

kwo commented Aug 22, 2012

Platform: Mac OSX 10.8

java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)

@miniway
Copy link
Member

miniway commented Aug 22, 2012

I think I need to test more on java7.

michaelklishin,

what was your mvn test result?

here are known test failures at a certain network configuration. I'm going to ignore them.

Failed tests:
testInvaid(zmq.TestAddress): Expected exception: java.lang.IllegalArgumentException
testConnectResolve(zmq.TestConnectResolve)

@aruld
Copy link

aruld commented Aug 22, 2012

I am running on Java 6 (java version "1.6.0_33") on OS X 10.8.

testProxyTcp() is getting stuck because of this IOException. If I ignore this test, all other tests pass.

Exception in thread "iothread-2" zmq.ZException$IOException: java.io.IOException: Broken pipe
at zmq.Signaler.send(Signaler.java:79)
at zmq.Mailbox.send(Mailbox.java:92)
at zmq.Ctx.send_command(Ctx.java:355)
at zmq.ZObject.send_command(ZObject.java:59)
at zmq.ZObject.send_command(ZObject.java:54)
at zmq.ZObject.send_pipe_term(ZObject.java:76)
at zmq.Pipe.terminate(Pipe.java:430)
at zmq.SessionBase.process_term(SessionBase.java:375)
at zmq.ZObject.process_command(ZObject.java:245)
at zmq.IOThread.in_event(IOThread.java:88)
at zmq.Poller.run(Poller.java:219)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcher.write0(Native Method)
at sun.nio.ch.FileDispatcher.write(FileDispatcher.java:39)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:69)
at sun.nio.ch.IOUtil.write(IOUtil.java:40)
at sun.nio.ch.SinkChannelImpl.write(SinkChannelImpl.java:149)
at zmq.Signaler.send(Signaler.java:72)
... 11 more
Exception in thread "Thread-2" java.lang.IllegalStateException
at zmq.SocketBase.recv(SocketBase.java:769)
at zmq.Device.device(Device.java:52)
at zmq.ZMQ.zmq_device(ZMQ.java:335)
at zmq.TestProxyTcp$Main.run(TestProxyTcp.java:275)

@aruld
Copy link

aruld commented Aug 22, 2012

Please ignore my last comment, I did not update your changes today. After pulling latest code base, I am able to run the tests fine. All tests pass for me on Java 6.

@miniway
Copy link
Member

miniway commented Aug 23, 2012

kwo,

It looks like your maven might choose openjdk.

getRemoteAddress exist only at openjdk's SocketChannel.

My test with oracle jdk7 works fine.

$ mvn -version
Apache Maven 3.0.3 (r1075438; 2011-03-01 02:31:09+0900)
Maven home: /opt/local/maven
Java version: 1.7.0_06, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8", arch: "x86_64", family: "mac"

@aruld
Copy link

aruld commented Aug 23, 2012

I believe the problem is, there were several new APIs added to SocketChannel in JDK 7. DummySocketChannel has to implement all those new methods in order to compile under JDK 7. getRemoteAddress() in SocketChannel (http://docs.oracle.com/javase/7/docs/api/java/nio/channels/SocketChannel.html#getRemoteAddress()) is a standard API that was introduced in JDK 7.

mvn test fails for me under Oracle JDK 7 due to this incompatibility. The only way I can think of is to stick with either JDK 6 or JDK 7, it is not possible to support both unfortunately.

@miniway
Copy link
Member

miniway commented Aug 23, 2012

Ah, you're right. I didn't look into jdk7 doc deeply and I forgot to run mvn clean.

I just simply added getRemoteAddress at the dummy channel. Please pull the latest

@michaelklishin
Copy link

@aruld is right: in JDK 7, there is a method added to java.nio.channels.SocketChannel that has java.net.SocketOption in the signature. That class is new in JDK 7. This means, in jeromq's particular case, tests won't compile under JDK 6 (the library should work fine).

Because JDK 7 is inevitable future and the only (recent) JDK you can get for recent OS X releases, I'd recommend going with 7 for development. These changes to the dummy channel are sufficient:

diff --git a/src/test/java/zmq/Helper.java b/src/test/java/zmq/Helper.java
index 0c34d1c..7d52b74 100644
--- a/src/test/java/zmq/Helper.java
+++ b/src/test/java/zmq/Helper.java
@@ -25,11 +25,13 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.net.SocketAddress;
+import java.net.SocketOption;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.SelectorProvider;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 import static org.junit.Assert.*;
 import static org.hamcrest.CoreMatchers.*;
@@ -49,8 +51,43 @@ public class Helper {
         protected DummySocketChannel(SelectorProvider provider) {
             super(provider);
         }
-        
-        public DummySocketChannel() {
+
+      @Override
+      public SocketChannel bind(SocketAddress local) throws IOException {
+        return null;
+      }
+
+      @Override
+      public SocketAddress getLocalAddress() throws IOException {
+        return null;
+      }
+
+      @Override
+      public <T> SocketChannel setOption(SocketOption<T> name, T value) throws IOException {
+        return null;
+      }
+
+      @Override
+      public <T> T getOption(SocketOption<T> name) throws IOException {
+        return null;
+      }
+
+      @Override
+      public Set<SocketOption<?>> supportedOptions() {
+        return null;
+      }
+
+      @Override
+      public SocketChannel shutdownInput() throws IOException {
+        return null;
+      }
+
+      @Override
+      public SocketChannel shutdownOutput() throws IOException {
+        return null;
+      }
+
+      public DummySocketChannel() {
             this(64);
         }
         public DummySocketChannel(int bufsize) {

@kwo
Copy link
Author

kwo commented Aug 23, 2012

I uninstalled OpenJDK as I wasn't sure which JVM maven was using. I pulled just now and am still getting an error albeit a different one:

[ERROR] /Users/karl/projects/jeromq/src/test/java/zmq/Helper.java:[45,18] error: DummySocketChannel is not abstract and does not override abstract method shutdownOutput() in SocketChannel

@aruld
Copy link

aruld commented Aug 23, 2012

@kwo It won't work until all the abstract methods are implemented from JDK 7 SocketChannel (shown in @michaelklishin patch).

I personally think Java 6 should be supported as it is widely used everywhere. I see the DummySocketChannel is only used in tests (TestEncoder), is there a different approach to implement those tests?

@michaelklishin
Copy link

One way is to replace that dummy channel with a mock (since it already does not do much). JDK 6 will be supported, the issue is with a particular part of the test suite, not the library.

@miniway
Copy link
Member

miniway commented Aug 23, 2012

Thanks for ideas.

I narrowed down base class of DummySocketChannel from SocketChannel to WritableByteChannel.

WritableByteChannel is jdk6/7 compatible.

@kwo
Copy link
Author

kwo commented Aug 23, 2012

Just pulled and all tests pass on JDK7

@kwo
Copy link
Author

kwo commented Aug 23, 2012

also tested on 1.6.0_33 and all tests pass

@kwo
Copy link
Author

kwo commented Aug 23, 2012

Closing issue: works on both JDK6 and 7

@kwo kwo closed this as completed Aug 23, 2012
@michaelklishin
Copy link

Now that both JDK 6 and JDK 7 are supported, I recommend adding jeromq to travis-ci.org to run CI against 3 JDKs:

I will be happy to help if you have questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants