尝试使用“with”在 gremlin 查询上设置唯一请求 ID 时的空指针

null pointer when trying to set unique request id on gremlin query using `with`

我正尝试按照 Neptune best practise.

中所述在 gremlin 查询上设置唯一的 requestId

但是当我这样做时,我在没有它的情况下工作正常的代码上得到一个空指针异常。

我正在使用 3.4.2 Gremlin 客户端驱动程序,Java 11,单元测试正在针对测试容器执行 运行 tinkerpop/gremlin-server:3.4.1

这是我的代码:

            GraphTraversalSource g = factory.getReadOnlyTraversal();

            return g.with(Tokens.REQUEST_ID, UUID.randomUUID()).V(group.getId()).
                    out("discussing").
                    project("id", "topic", "comments").
                    by(T.id).
                    by("topic").
                    by(__.in("commenting_on").order(Scope.local).
                        project("id", "text", "timestamp", "user").
                        by(T.id).by("text").by("timestamp").
                        by(__.in("is_commenting").valueMap(true)).fold()
                    )
                    .toStream()
                    .map(discussionBuilder::from)
                    .collect(Collectors.toSet());

这是堆栈跟踪:

java.util.concurrent.CompletionException: java.lang.NullPointerException

    at java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:412)
    at java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2044)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:119)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.hasNext(ResultSet.java:171)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.next(ResultSet.java:178)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.next(ResultSet.java:165)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:140)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:125)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal.nextTraverser(DriverRemoteTraversal.java:106)
    at org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.processNextStart(RemoteStep.java:80)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
    at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:204)
    at org.apache.tinkerpop.gremlin.process.traversal.Traversal.forEachRemaining(Traversal.java:265)
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at com.yooblr.yooblrweb.domain.discussions.repositories.GremlinDiscussionsRepositoryImpl.getDiscussions(GremlinDiscussionsRepositoryImpl.java:54)
    at com.yooblr.yooblrweb.domain.discussions.repositories.GremlinDiscussionsRepositoryImplTest.whenGettingDiscussions(GremlinDiscussionsRepositoryImplTest.java:70)
    at com.yooblr.yooblrweb.domain.discussions.repositories.GremlinDiscussionsRepositoryImplTest.multiple(GremlinDiscussionsRepositoryImplTest.java:38)
...
Caused by: java.lang.NullPointerException
    at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:221)
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:198)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinSaslAuthenticationHandler.channelRead0(Handler.java:124)
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinSaslAuthenticationHandler.channelRead0(Handler.java:68)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at org.apache.tinkerpop.gremlin.driver.handler.WebSocketClientHandler.channelRead0(WebSocketClientHandler.java:89)
...

当我尝试设置查询超时时发生同样的问题:

return g.with(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT, 500L).V(group.getId()).

此功能是在 Apache TinkerPop 版本 3.4.2 中引入的。您需要客户端和服务器都处于 3.4.2 级别(或更高级别)才能使其工作。 Amazon Neptune 目前支持 3.4.1 级别的 Apache TinkerPop。一旦支持 3.4.2,一切都应该可以正常工作。对于文档可能造成的任何混淆,我们深表歉意。