edge通过highway方式时数据带日期类型转换失败,rest方式没有问题
java.lang.NumberFormatException: For input string: "2022-05-31T09:16:38.941Z" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) ~[?:?] at java.lang.Long.parseLong(Long.java:711) ~[?:?] at org.apache.servicecomb.foundation.protobuf.internal.schema.serializer.scalar.Int64WriteSchemas$Int64DynamicSchema.writeTo(Int64WriteSchemas.java:66) ~[foundation-protobuf-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.protobuf.internal.schema.serializer.MessageWriteSchema.writeFromMap(MessageWriteSchema.java:192) ~[foundation-protobuf-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.protobuf.internal.schema.serializer.MessageWriteSchema.writeTo(MessageWriteSchema.java:151) ~[foundation-protobuf-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.protobuf.RootSerializer.serialize(RootSerializer.java:35) ~[foundation-protobuf-2.7.3.jar:2.7.3] at org.apache.servicecomb.codec.protobuf.definition.RequestRootSerializer.serialize(RequestRootSerializer.java:46) ~[common-protobuf-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayOutputStream.write(HighwayOutputStream.java:32) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayCodec.encodeRequest(HighwayCodec.java:57) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayClientPackage.createStream(HighwayClientPackage.java:42) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConnection.writeToBufferQueue(TcpClientConnection.java:146) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConnection.send(TcpClientConnection.java:122) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayClient.send(HighwayClient.java:97) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayTransport.send(HighwayTransport.java:55) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.core.handler.impl.TransportClientHandler.handle(TransportClientHandler.java:42) ~[java-chassis-core-2.7.3.jar:2.7.3] at org.apache.servicecomb.core.Invocation.next(Invocation.java:274) ~[java-chassis-core-2.7.3.jar:2.7.3] at org.apache.servicecomb.loadbalance.LoadbalanceHandler.send(LoadbalanceHandler.java:192) ~[handler-loadbalance-2.7.3.jar:2.7.3] at org.apache.servicecomb.loadbalance.LoadbalanceHandler.handle(LoadbalanceHandler.java:134) ~[handler-loadbalance-2.7.3.jar:2.7.3] at org.apache.servicecomb.core.Invocation.next(Invocation.java:274) ~[java-chassis-core-2.7.3.jar:2.7.3] at com.zhuanjiaodian.threewho.edge.handler.EdgeSecurityHandler._checkMethod(EdgeSecurityHandler.java:211) ~[classes/:?] at com.zhuanjiaodian.threewho.edge.handler.EdgeSecurityHandler.checkMethod(EdgeSecurityHandler.java:172) ~[classes/:?] at com.zhuanjiaodian.threewho.edge.handler.EdgeSecurityHandler.lambda$handle$0(EdgeSecurityHandler.java:108) ~[classes/:?] at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?] at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?] at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?] at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?] at org.apache.servicecomb.provider.pojo.HandlerInvocationCaller.lambda$completableFutureInvoke$0(HandlerInvocationCaller.java:53) ~[provider-pojo-2.7.3.jar:2.7.3] at org.apache.servicecomb.swagger.invocation.AsyncResponse.complete(AsyncResponse.java:46) ~[swagger-invocation-core-2.7.3.jar:2.7.3] at org.apache.servicecomb.core.provider.consumer.InvokerUtils.lambda$reactiveInvoke$0(InvokerUtils.java:326) ~[java-chassis-core-2.7.3.jar:2.7.3] at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?] at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?] at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?] at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?] at org.apache.servicecomb.core.provider.consumer.InvokerUtils.lambda$null$1(InvokerUtils.java:388) ~[java-chassis-core-2.7.3.jar:2.7.3] at org.apache.servicecomb.loadbalance.LoadbalanceHandler.lambda$handle$0(LoadbalanceHandler.java:114) ~[handler-loadbalance-2.7.3.jar:2.7.3] at org.apache.servicecomb.loadbalance.LoadbalanceHandler.lambda$send$1(LoadbalanceHandler.java:203) ~[handler-loadbalance-2.7.3.jar:2.7.3] at org.apache.servicecomb.swagger.invocation.AsyncResponse.complete(AsyncResponse.java:46) ~[swagger-invocation-core-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayClient.lambda$null$0(HighwayClient.java:127) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.core.provider.consumer.ReactiveResponseExecutor.execute(ReactiveResponseExecutor.java:28) ~[java-chassis-core-2.7.3.jar:2.7.3] at org.apache.servicecomb.transport.highway.HighwayClient.lambda$send$1(HighwayClient.java:101) ~[transport-highway-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.AsyncResultCallback.success(AsyncResultCallback.java:26) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.client.tcp.TcpRequest.onReply(TcpRequest.java:49) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConnection.onReply(TcpClientConnection.java:309) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.server.TcpParser.onReadOnePackage(TcpParser.java:124) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.server.TcpParser.onParse(TcpParser.java:115) ~[foundation-vertx-2.7.3.jar:2.7.3] at io.vertx.core.parsetools.impl.RecordParserImpl.handleParsing(RecordParserImpl.java:214) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.parsetools.impl.RecordParserImpl.handle(RecordParserImpl.java:285) ~[vertx-core-4.2.7.jar:4.2.7] at org.apache.servicecomb.foundation.vertx.server.TcpParser.handle(TcpParser.java:131) ~[foundation-vertx-2.7.3.jar:2.7.3] at org.apache.servicecomb.foundation.vertx.server.TcpParser.handle(TcpParser.java:32) ~[foundation-vertx-2.7.3.jar:2.7.3] at io.vertx.core.net.impl.NetSocketImpl.lambda$new$1(NetSocketImpl.java:98) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:240) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:130) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.net.impl.NetSocketImpl$DataMessageHandler.handle(NetSocketImpl.java:418) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:50) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:168) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:394) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:155) ~[vertx-core-4.2.7.jar:4.2.7] at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:153) ~[vertx-core-4.2.7.jar:4.2.7] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.74.Final.jar:4.1.74.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.74.Final.jar:4.1.74.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.74.Final.jar:4.1.74.Final] at java.lang.Thread.run(Thread.java:833) ~[?:?]
数据类: public class GroupModel extends Model { @ApiModelProperty("群组id") @Id private String id; @ApiModelProperty("修改时间") @JsonView(RoleLevel.ManaLevel.class) private Date updateDate; }
通过前端传递 updateDate: type: "string" format: "date-time" description: "修改时间" 数据,通过edge网关传递到微服务的时候,只判断类型,没有判断数据需要转换的格式,微服务之间通过highway没有什么问题,但是前端到网关是json格式,由于微服务配置的通讯方式为rest和highway,这样日期类型在使用highway的时候会出问题,有没有什么方法能够转换一下日期格式?或者是在edge中转换类型时引入format方法?
错误堆栈是 edge service 抛出来的吗? 看起来有点奇怪, 比较长。
这个场景看起来是一个没支持到的场景, edge service没有识别 format, 在edge的类型是 String, 导致序列化的时候失败。
是edge service抛出,主要是没有为定义date类型,都定义为Int64,是否可以独立一个类型date类型
那个@id和@JSONVIEW(RoleLevel.ManaLevel.class)这两个注解是你们自定义的注解吗还是哪儿的注解
这个是MongoDB的id和json注解,没什么关系,代码跟踪结果是,前端传到edge中为时间字符串,在数据转换的时候对应的是Int64,所以转换失败
I add a fix for this, see: https://github.com/apache/servicecomb-java-chassis/pull/3348
BTW:
As this fix indicated, recommend not use highway only when it is needed, and use simple date types for highway only. Highway date type may produce different output than rest. Highway use protobuffer as encoding and not fully compatible with open api.