apache / apache/incubator-seata

Failed to get available servers NPE problem

Open
#2,499 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

- [x] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.

### Ⅰ. Issue Description

### Ⅱ. Describe what happened

在k8s环境中使用服务名作为seata server的地址,比如:seata-server:8091,如果seata-server不可用,即无法获取seata-server的IP,则io.seata.common.util.NetUtil.toStringAddress(NetUtil.java:74)会有NPE问题。

```
2020-04-01 09:51:07.208 ERROR 8 --- [ main] i.s.c.r.netty.NettyClientChannelManager : Failed to get available servers: null

java.lang.NullPointerException: null
at io.seata.common.util.NetUtil.toStringAddress(NetUtil.java:74) ~[seata-all-1.1.0.jar!/:1.1.0]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[na:1.8.0_222]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_222]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[na:1.8.0_222]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[na:1.8.0_222]
```

### Ⅲ. Describe what you expected to happen
封装此错误,改为警告提示,而不是抛出这个错误

### Ⅳ. How to reproduce it (as minimally and precisely as possible)

1. 在k8s环境部署seata client项目
2. 配置一个不可用的seata server地址

### Ⅴ. Anything else we need to know?

### Ⅵ. Environment:

- version : 1.1.0

Contributor guide

Open the contributing guide

Research direction

Start at io.seata.common.util.NetUtil.java:74 and follow the call from NettyClientChannelManager that logs “Failed to get available servers.” Reproduce the case with an unavailable seata-server address in Kubernetes, then verify the failure is handled as a warning without a NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kubernetes
Domain
backend, distributed-systems, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.