当前位置:首页 > 服务端 > 【Azure Spring Cloud】Java Spring Cloud 应用部署到Azure上后,发现大量的 java.lang.NullPointerException: null at io.lettuce.core.protocol.CommandHandler.writeSingleCommand(CommandHandler.java:426) at ... 异常

【Azure Spring Cloud】Java Spring Cloud 应用部署到Azure上后,发现大量的 java.lang.NullPointerException: null at io.lettuce.core.protocol.CommandHandler.writeSingleCommand(CommandHandler.java:426) at ... 异常

Azure Spring Cloud 是什么?

借助 Azure Spring Cloud,可以轻松地将 Spring Boot 微服务应用程序部署到 Azure,不需更改任何代码。 该服务管理 Spring Cloud 应用程序的基础结构,因此开发人员可以专注于其代码。 Azure Spring Cloud 可以通过以下方法提供生命周期管理:综合性监视和诊断、配置管理、服务发现、CI/CD 集成、蓝绿部署等。 Link: https://docs.azure.cn/zh-cn/spring-cloud/overview

【Azure Spring Cloud】Java Spring Cloud 应用部署到Azure上后,发现大量的 java.lang.NullPointerException: null at io.lettuce.core.protocol.CommandHandler.writeSingleCommand(CommandHandler.java:426) at ... 异常 _ JavaClub全栈架构师技术笔记

 

问题描述

在本地运行正常的Spring Cloud项目,部署在Azure Spring Cloud服务后,在日志中,发现大量的null pointer exception

java.lang.NullPointerException: null 
at io.lettuce.core.protocol.CommandHandler.writeSingleCommand(CommandHandler.java:426) 
at io.lettuce.core.protocol.CommandHandler.write(CommandHandler.java:378) 
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) 
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) 
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) 
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) 
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:808) 
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) 
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:294) 
at io.lettuce.core.protocol.DefaultEndpoint.channelWriteAndFlush(DefaultEndpoint.java:392) 
at io.lettuce.core.protocol.DefaultEndpoint.writeToChannelAndFlush(DefaultEndpoint.java:332) 
at io.lettuce.core.protocol.DefaultEndpoint.write(DefaultEndpoint.java:162) 
at io.lettuce.core.protocol.DefaultEndpoint$RetryListener.requeueCommands(DefaultEndpoint.java:1002) 
at io.lettuce.core.protocol.DefaultEndpoint$RetryListener.lambda$potentiallyRequeueCommands$0(DefaultEndpoint.java:989) 
at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) 
at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:106) 
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) 

问题解决

根据在Github和stackoverflow中查看到的信息,判断这是一个和sleuth版本相关,在新的版本中,默认启用了redis配置。通过 spring.sleuth.redis.enabled=false 来关闭默认配置, Null Point Exception问题解决。

 

StackOverflow :

I use spring-session-data-redis to manage sessions. It will get session data from redis before every request. But it throws a NPE when get session from redis. And if I remove spring-cloud-starter-sleuth dependency, it won't happend.

springboot version: 2.3.8.RELEASE

springcloud version: Hoxton.SR10

Here is the exception information:

java.lang.NullPointerException: null
    at io.lettuce.core.protocol.CommandHandler.writeSingleCommand(CommandHandler.java:426) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.lettuce.core.protocol.CommandHandler.write(CommandHandler.java:378) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:808) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:294) ~[netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.lettuce.core.protocol.DefaultEndpoint.channelWriteAndFlush(DefaultEndpoint.java:392) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.lettuce.core.protocol.DefaultEndpoint.writeToChannelAndFlush(DefaultEndpoint.java:332) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.lettuce.core.protocol.DefaultEndpoint.write(DefaultEndpoint.java:162) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.lettuce.core.protocol.DefaultEndpoint$RetryListener.requeueCommands(DefaultEndpoint.java:1002) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.lettuce.core.protocol.DefaultEndpoint$RetryListener.lambda$potentiallyRequeueCommands$0(DefaultEndpoint.java:989) ~[lettuce-core-5.3.6.RELEASE.jar:5.3.6.RELEASE]
    at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:106) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:164) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497) [netty-transport-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.58.Final.jar:4.1.58.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.58.Final.jar:4.1.58.Final]

Answer:

I have resolved this problem. It seems that there are some bugs in this sleuth version. I compare this new version with the old version we used, the old version sleuth doesn't intercept the redis request, but this new version will. If I disable this configuration, it won't happen. I use 'spring.sleuth.redis.enabled=false' to disable redis sleuth configuration. It is enabled by default. 

 

GitHub: https://githubmemory.com/repo/spring-cloud/spring-cloud-sleuth/issues/1992

 

作者:路边两盏灯
来源链接:https://www.cnblogs.com/lulight/p/15328955.html

版权声明:
1、Java侠(https://www.javaxia.com)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaxia.com/server/124681.html

分享给朋友:

“【Azure Spring Cloud】Java Spring Cloud 应用部署到Azure上后,发现大量的 java.lang.NullPointerException: null at io.lettuce.core.protocol.CommandHandler.writeSingleCommand(CommandHandler.java:426) at ... 异常” 的相关文章