Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.1-dp4
    • Fix Version/s: 1.1-beta
    • Component/s: Core
    • Security Level: Public
    • Labels:
    • Environment:
      All

      Description

      When objects are stored as non-strings in Couchbase and then loaded through a View, the SDK currently casts every document to a string. This works fine for JSON documents, but as soon as you want to store serialized objects it breaks.

      Implicit casting is not needed in this place (see fix).

      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 - - edited

        Here is a quick sample on how to reproduce it, but I'm adding a correct test case to the code as well (the view used is just the default "emit key and null" view with no reduce).

        import com.couchbase.client.CouchbaseClient;
        import com.couchbase.client.CouchbaseConnectionFactory;
        import com.couchbase.client.protocol.views.Query;
        import com.couchbase.client.protocol.views.View;
        import com.couchbase.client.protocol.views.ViewResponse;
        import com.couchbase.client.protocol.views.ViewRow;
        import java.io.IOException;
        import java.net.URI;
        import java.util.Arrays;
        import java.util.Date;
        import java.util.Iterator;

        public class BinaryviewTest {

        /**

        • @param args the command line arguments
          */
          public static void main(String[] args) throws IOException {

        // Initialize Connection
        CouchbaseClient cb = new CouchbaseClient(
        new CouchbaseConnectionFactory(
        Arrays.asList(
        URI.create("http://192.168.1.105:8091/pools")
        ),
        "default",
        ""
        )
        );

        // Store binary objects
        Object ob1 = new Date();
        cb.set("date1", 0, ob1);

        Object result = cb.get("date1");
        System.out.println(result.getClass());

        Query query = new Query();
        query.setIncludeDocs(true);
        View view = cb.getView("testing", "binary");
        ViewResponse response = cb.query(view, query);

        Iterator<ViewRow> iterator = response.iterator();
        ViewRow row;
        while(iterator.hasNext())

        { row = iterator.next(); Object obj = row.getDocument(); System.out.println(obj.getClass()); }

        cb.shutdown();
        }
        }

        When run two times, this raises the exception as described here: http://www.couchbase.com/forums/thread/couchbase-2-view-non-json-docs

        I'll update it when I have the fix and test ready.

        Show
        daschl Michael Nitschinger added a comment - - edited Here is a quick sample on how to reproduce it, but I'm adding a correct test case to the code as well (the view used is just the default "emit key and null" view with no reduce). import com.couchbase.client.CouchbaseClient; import com.couchbase.client.CouchbaseConnectionFactory; import com.couchbase.client.protocol.views.Query; import com.couchbase.client.protocol.views.View; import com.couchbase.client.protocol.views.ViewResponse; import com.couchbase.client.protocol.views.ViewRow; import java.io.IOException; import java.net.URI; import java.util.Arrays; import java.util.Date; import java.util.Iterator; public class BinaryviewTest { /** @param args the command line arguments */ public static void main(String[] args) throws IOException { // Initialize Connection CouchbaseClient cb = new CouchbaseClient( new CouchbaseConnectionFactory( Arrays.asList( URI.create("http://192.168.1.105:8091/pools") ), "default", "" ) ); // Store binary objects Object ob1 = new Date(); cb.set("date1", 0, ob1); Object result = cb.get("date1"); System.out.println(result.getClass()); Query query = new Query(); query.setIncludeDocs(true); View view = cb.getView("testing", "binary"); ViewResponse response = cb.query(view, query); Iterator<ViewRow> iterator = response.iterator(); ViewRow row; while(iterator.hasNext()) { row = iterator.next(); Object obj = row.getDocument(); System.out.println(obj.getClass()); } cb.shutdown(); } } When run two times, this raises the exception as described here: http://www.couchbase.com/forums/thread/couchbase-2-view-non-json-docs I'll update it when I have the fix and test ready.
        Show
        daschl Michael Nitschinger added a comment - See http://review.couchbase.com/#/c/21305/
        Hide
        daschl Michael Nitschinger added a comment -

        pushed to master, will be available in dp5.

        Show
        daschl Michael Nitschinger added a comment - pushed to master, will be available in dp5.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes