Coder Social home page Coder Social logo

Comments (18)

miniway avatar miniway commented on June 27, 2024

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

from jeromq.

michaelklishin avatar michaelklishin commented on June 27, 2024

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

from jeromq.

kwo avatar kwo commented on June 27, 2024

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)

from jeromq.

miniway avatar miniway commented on June 27, 2024

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)

from jeromq.

aruld avatar aruld commented on June 27, 2024

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)

from jeromq.

aruld avatar aruld commented on June 27, 2024

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.

from jeromq.

miniway avatar miniway commented on June 27, 2024

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"

from jeromq.

aruld avatar aruld commented on June 27, 2024

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.

from jeromq.

miniway avatar miniway commented on June 27, 2024

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

from jeromq.

michaelklishin avatar michaelklishin commented on June 27, 2024

@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) {

from jeromq.

kwo avatar kwo commented on June 27, 2024

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

from jeromq.

aruld avatar aruld commented on June 27, 2024

@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?

from jeromq.

michaelklishin avatar michaelklishin commented on June 27, 2024

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.

from jeromq.

miniway avatar miniway commented on June 27, 2024

Thanks for ideas.

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

WritableByteChannel is jdk6/7 compatible.

from jeromq.

kwo avatar kwo commented on June 27, 2024

Just pulled and all tests pass on JDK7

from jeromq.

kwo avatar kwo commented on June 27, 2024

also tested on 1.6.0_33 and all tests pass

from jeromq.

kwo avatar kwo commented on June 27, 2024

Closing issue: works on both JDK6 and 7

from jeromq.

michaelklishin avatar michaelklishin commented on June 27, 2024

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.

from jeromq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.