Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.5
    • Component/s: Core
    • Security Level: Public
    • Labels:
      None

      Description

      See this forum question for a description of the issue as well as the fix for it:

      http://www.couchbase.com/forums/thread/using-couchbaseclient-inside-netty-server

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        daschl Michael Nitschinger added a comment -

        will be available in 1.1.5.

        Show
        daschl Michael Nitschinger added a comment - will be available in 1.1.5.
        Hide
        daschl Michael Nitschinger added a comment -

        I could reproduce this issue by instantiating a couchbase server inside a handler. If you instantiate the connection outside it works. Here is the code to reproduce it:

        when you run it in the IDE and telnet to localhost 8080 it will die and throw the exception:

        package com.couchbase.nettyexample;

        import com.couchbase.client.CouchbaseClient;
        import java.io.IOException;
        import java.net.InetSocketAddress;
        import java.net.URI;
        import java.util.Arrays;
        import java.util.concurrent.Executors;
        import org.jboss.netty.bootstrap.ServerBootstrap;
        import org.jboss.netty.channel.ChannelHandlerContext;
        import org.jboss.netty.channel.ChannelPipeline;
        import org.jboss.netty.channel.ChannelPipelineFactory;
        import org.jboss.netty.channel.Channels;
        import org.jboss.netty.channel.MessageEvent;
        import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
        import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

        /**

        • Hello world!
          *
          */
          public class App {
          private final int port = 8080;
          private CouchbaseClient client;

        public void run() throws IOException {
        ServerBootstrap bootstrap = new ServerBootstrap(
        new NioServerSocketChannelFactory(
        Executors.newCachedThreadPool(),
        Executors.newCachedThreadPool()
        )
        );

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception

        { return Channels.pipeline(new EchoServerHandler()); }

        });

        bootstrap.bind(new InetSocketAddress(port));
        }

        public static void main(String[] args) throws IOException

        { new App().run(); }

        class EchoServerHandler extends SimpleChannelUpstreamHandler {

        private CouchbaseClient client;

        public EchoServerHandler() throws IOException

        { this.client = new CouchbaseClient( Arrays.asList(URI.create("http://localhost:8091/pools")), "default", "" ); this.client.set("received", 0, "foo"); }

        @Override
        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)

        { System.out.println("Received Message"); System.out.println(client.get("received")); }

        }
        }

        Show
        daschl Michael Nitschinger added a comment - I could reproduce this issue by instantiating a couchbase server inside a handler. If you instantiate the connection outside it works. Here is the code to reproduce it: when you run it in the IDE and telnet to localhost 8080 it will die and throw the exception: package com.couchbase.nettyexample; import com.couchbase.client.CouchbaseClient; import java.io.IOException; import java.net.InetSocketAddress; import java.net.URI; import java.util.Arrays; import java.util.concurrent.Executors; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipelineFactory; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; /** Hello world! * */ public class App { private final int port = 8080; private CouchbaseClient client; public void run() throws IOException { ServerBootstrap bootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool() ) ); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(new EchoServerHandler()); } }); bootstrap.bind(new InetSocketAddress(port)); } public static void main(String[] args) throws IOException { new App().run(); } class EchoServerHandler extends SimpleChannelUpstreamHandler { private CouchbaseClient client; public EchoServerHandler() throws IOException { this.client = new CouchbaseClient( Arrays.asList(URI.create("http://localhost:8091/pools")), "default", "" ); this.client.set("received", 0, "foo"); } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { System.out.println("Received Message"); System.out.println(client.get("received")); } } }
        Show
        daschl Michael Nitschinger added a comment - http://review.couchbase.com/#/c/22589/

          People

          • Assignee:
            daschl Michael Nitschinger
            Reporter:
            mikew Mike Wiederhold
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes