• dubbo服务使用spring-data-mongodb进行时间查询的bug记录


    一、项目情况:spring-boot+mongodb+dubbo。

    二、问题:调用dubbo服务并使用spring-data-mongodb的gte,lte时间段比较查询,

    @Reference(retries = 1)
    private FunctionService functionService; //dubbo服务
    
    //mongodb gte、lte查询
    Date beginOfToday = DateUtils.getBeginOfToday();
    Date endOfToday
    = DateUtils.getEndOfToday();
    Criteria criteria
    = Criteria.where(Function.FIELD_CREATED_TIME).gte(beginOfToday).lte(endOfToday);
    List
    <Function> todayFunctionList= functionService.find(new Query(criteria));

    报错信息如下:

    User: null
    系统发生异常
    
    java.lang.RuntimeException: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Object.
    org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Object.
        at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
        at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
        at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
        at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:210)
        at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:128)
        at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61)
        at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
        at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
        at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
        at org.bson.codecs.BsonDocumentCodec.writeValue(BsonDocumentCodec.java:133)
        at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:112)
        at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:40)
        at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:253)
        at com.mongodb.connection.RequestMessage.addDocument(RequestMessage.java:205)
        at com.mongodb.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:75)
        at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160)
        at com.mongodb.connection.CommandProtocol.sendMessage(CommandProtocol.java:192)
        at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:111)
        at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159)
        at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286)
        at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173)
        at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215)
        at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206)
        at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112)
        at com.mongodb.operation.FindOperation$1.call(FindOperation.java:487)
        at com.mongodb.operation.FindOperation$1.call(FindOperation.java:482)
        at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239)
        at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212)
        at com.mongodb.operation.FindOperation.execute(FindOperation.java:482)
        at com.mongodb.operation.FindOperation.execute(FindOperation.java:79)
        at com.mongodb.Mongo.execute(Mongo.java:772)
        at com.mongodb.Mongo$2.execute(Mongo.java:759)
        at com.mongodb.DBCursor.initializeCursor(DBCursor.java:851)
        at com.mongodb.DBCursor.hasNext(DBCursor.java:152)
        at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1943)
        at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1763)
        at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1746)
        at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:624)
        at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:615)
        at ai.deepbrain.iengine.admin.service.impl.base.MongoBaseCrudServiceImpl.find(MongoBaseCrudServiceImpl.java:99)
        at com.alibaba.dubbo.common.bytecode.Wrapper28.invokeMethod(Wrapper28.java)
        at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
        at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
        at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
        at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:70)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:132)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:113)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
        at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
        at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

    三、本应用中使用gte,lte查询没问题

    @Autowired
    private FunctionTagService functionTagService;//本应用的Service
    
    //mongodb gte、lte查询 Date beginOfToday
    = DateUtils.getBeginOfToday(); Date endOfToday = DateUtils.getEndOfToday(); Criteria criteria = Criteria.where(FunctionType.FIELD_CREATED_TIME).gte(beginOfToday).lte(endOfToday); List<FunctionTag> tagList = functionTagService.find(new Query(criteria));

    四、问题分析

    先记录一下问题,猜想是dubbo在序列化gte、lte请求参数时的bug。有空研究....有大神知道的话烦请告知下,多谢。

  • 相关阅读:
    继承和派生
    面向过程和面向对象 , 面向对象基础
    numpy模块、matplotlib模块、pandas模块
    包 ,模块(time、datetime、random、hashlib、typing、requests、re)
    os模块 sys模块 json/pickle 模块 logging模块
    python模块基础
    匿名函数 python内置方法(max/min/filter/map/sorted/reduce)面向过程编程
    最简单的注册美区Apple ID方法
    迭代器 生成器 函数递归
    ODBC连接时报错不可识别的数据库格式
  • 原文地址:https://www.cnblogs.com/shuaiqing/p/9370031.html
Copyright © 2020-2023  润新知