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

NullPointerException with OpenTracing

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 3.1.6, 3.2.0
    • 3.2.1, 3.1.7
    • tracing
    • None
    • 1

    Description

      When tracing is enabled with Open-Tracing, a NullPointerException is occurring on queries.

      At this point, `ChunkedMessageHandler#write`

      setCommonDispatchSpanAttributes(
       currentDispatchSpan,
       ctx.channel().attr(ChannelAttributes.CHANNEL_ID_KEY).get(),
       ioContext.localHostname(),
       ioContext.localPort(),
       endpoint.remoteHostname(),
       endpoint.remotePort(),
       currentRequest.operationId()
       );
      

      the value of `ctx.channel().attr(ChannelAttributes.CHANNEL_ID_KEY).get()` is null and with Brave's tracer, if a null value is stored, a nullpointerexception is thrown breaking the request.

       

      StackTrace:

      2021-07-23 15:27:20,834 [http-nio-8080-exec-4] ERROR com.inditex.aqsw.framework.service.webmvc.exception.RestFaultHandler - value of db.couchbase.local_id == null
      java.lang.NullPointerException: value of db.couchbase.local_id == null
      	at brave.handler.MutableSpan.tag(MutableSpan.java:880)
      	at brave.RealSpan.tag(RealSpan.java:112)
      	at brave.opentracing.BraveSpan.setTag(BraveSpan.java:74)
      	at brave.opentracing.BraveSpan.setTag(BraveSpan.java:35)
      	at com.couchbase.client.tracing.opentracing.OpenTracingRequestSpan.attribute(OpenTracingRequestSpan.java:71)
      	at com.couchbase.client.core.io.netty.TracingUtils.setCommonDispatchSpanAttributes(TracingUtils.java:48)
      	at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.write(ChunkedMessageHandler.java:170)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702)
      	at com.couchbase.client.core.io.netty.ChunkedHandlerSwitcher.write(ChunkedHandlerSwitcher.java:91)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
      	at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
      	at com.couchbase.client.core.deps.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
      	at com.couchbase.client.core.deps.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
      	at com.couchbase.client.core.deps.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
      	at com.couchbase.client.core.deps.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
      	at com.couchbase.client.core.deps.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
      	at com.couchbase.client.core.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      	Suppressed: java.lang.Exception: #block terminated with an error
      		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
      		at reactor.core.publisher.Mono.block(Mono.java:1703)
      		at com.inditex.aqsw.framework.data.couchbase.template.customOps.OriginalExecutableFindByQueryOperationSupport$ExecutableFindByQuerySupport.count(OriginalExecutableFindByQueryOperationSupport.java:135)
      		at org.springframework.data.couchbase.repository.support.SimpleCouchbaseRepository.count(SimpleCouchbaseRepository.java:142)
      		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      

       

      Attachments

        For Gerrit Dashboard: JCBC-1850
        # Subject Branch Project Status CR V

        Activity

          jorgerma Jorge Rodríguez created issue -
          daschl Michael Nitschinger made changes -
          Field Original Value New Value
          Status New [ 10003 ] Open [ 1 ]

          couchbase-opentracing versions with which I have tested that occur are: 0.3.6 and 1.0.0

          jorgerma Jorge Rodríguez added a comment - couchbase-opentracing versions with which I have tested that occur are: 0.3.6 and 1.0.0

          Thanks for reporting - yeah I think we can improve it to not set null values as attributes.

          daschl Michael Nitschinger added a comment - Thanks for reporting - yeah I think we can improve it to not set null values as attributes.
          daschl Michael Nitschinger made changes -
          Fix Version/s 3.1.7 [ 17922 ]
          Fix Version/s 3.2.1 [ 17634 ]
          daschl Michael Nitschinger made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          daschl Michael Nitschinger added a comment - Fix in progress: http://review.couchbase.org/c/couchbase-jvm-clients/+/158097
          daschl Michael Nitschinger made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]

          Hi Michael Nitschinger
          Thank you for the quick solution.

          Maybe, as a temporary solution it is ok but I think you should check why the value of channelId is null.

          On the other hand, do you have release date with this fix?

           

          Thank you very much

          jorgerma Jorge Rodríguez added a comment - Hi Michael Nitschinger Thank you for the quick solution. Maybe, as a temporary solution it is ok but I think you should check why the value of channelId is null. On the other hand, do you have release date with this fix?   Thank you very much

          People

            daschl Michael Nitschinger
            jorgerma Jorge Rodríguez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty