Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-40

paginatedQuery throws NoSuchElementException and NPE

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1dp
    • Fix Version/s: 1.1-beta
    • Component/s: Core
    • Security Level: Public
    • Labels:
      None
    • Environment:
      java

      Description

      view iteration is incomplete and throws exceptions for
      groovy code:
      paginator = client.paginatedQuery(view, query, n)
      while (paginator.hasNext())

      { row = paginator.next() // Exception on this line ... }

      java.util.NoSuchElementException
      at java.util.LinkedList$ListItr.next(LinkedList.java:698)
      at com.couchbase.client.protocol.views.Paginator.next(Paginator.java:76)
      at com.couchbase.client.protocol.views.Paginator.next(Paginator.java:35)
      at java_util_Iterator$next.call(Unknown Source)

      AND

      java.lang.NullPointerException
      at com.couchbase.client.protocol.views.Paginator.getNextPage(Paginator.java:93)
      at com.couchbase.client.protocol.views.Paginator.hasNext(Paginator.java:67)
      at java_util_Iterator$hasNext.call(Unknown Source)

      Paginator also has a couple odd returns
      1) next() can return null, but it should never return null unless lastRow is null. I don't think lastRow should ever be null.
      2) getNextPage() has a return type, HttpFuture<ViewResponse>, but always returns null

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

        Activity

        Hide
        rags Raghavan Srinivas (Inactive) added a comment -

        This revolves around getKey() returning a string which is not the case always. It could return other types (such as int) and this will affect the way PaginatedQuery and other queries behave.

        Show
        rags Raghavan Srinivas (Inactive) added a comment - This revolves around getKey() returning a string which is not the case always. It could return other types (such as int) and this will affect the way PaginatedQuery and other queries behave.
        Hide
        ingenthr Matt Ingenthron added a comment -

        In an email, Steven Cooke commented:

        A couple other things I noticed:

        The fix breaks all the original test cases as return type of next is no longer the same. If the API is intended to be non-breaking, the
        test cases and next should be reverted.

        The private method
        getNextPage has a return value that is never used. This looks fishy

        Show
        ingenthr Matt Ingenthron added a comment - In an email, Steven Cooke commented: A couple other things I noticed: The fix breaks all the original test cases as return type of next is no longer the same. If the API is intended to be non-breaking, the test cases and next should be reverted. The private method getNextPage has a return value that is never used. This looks fishy
        Hide
        ingenthr Matt Ingenthron added a comment -

        This isn't intended to be API compatible actually. Rags and I talked through it and decided that the odd returns of nulls were odd. I don't know that the API you see here is final either.

        We would appreciate any additional feedback on this API or how you think it should work.

        Once we hit beta, we'll keep the API stable.

        Show
        ingenthr Matt Ingenthron added a comment - This isn't intended to be API compatible actually. Rags and I talked through it and decided that the odd returns of nulls were odd. I don't know that the API you see here is final either. We would appreciate any additional feedback on this API or how you think it should work. Once we hit beta, we'll keep the API stable.
        Show
        daschl Michael Nitschinger added a comment - http://review.couchbase.org/#/c/22513/
        Hide
        daschl Michael Nitschinger added a comment -

        Fixed and pushed to master. Will be available in dp5/beta.

        Show
        daschl Michael Nitschinger added a comment - Fixed and pushed to master. Will be available in dp5/beta.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes