From 7e7b9a22c6bec0baf3d5b05e2b0c2de4d4d953ee Mon Sep 17 00:00:00 2001 From: niu-dali <112364662+niu-dali@users.noreply.github.com> Date: Fri, 21 Apr 2023 22:27:46 +0800 Subject: [PATCH] fix NullPointerException fix "NullPointerException throw by maybeReadTimeOut() that can cause Eureka cluster registration inconsistency" https://github.com/Netflix/eureka/issues/1497 --- .../eureka/cluster/ReplicationTaskProcessor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eureka-core/src/main/java/com/netflix/eureka/cluster/ReplicationTaskProcessor.java b/eureka-core/src/main/java/com/netflix/eureka/cluster/ReplicationTaskProcessor.java index 961385b31a..01e28fc32e 100644 --- a/eureka-core/src/main/java/com/netflix/eureka/cluster/ReplicationTaskProcessor.java +++ b/eureka-core/src/main/java/com/netflix/eureka/cluster/ReplicationTaskProcessor.java @@ -193,11 +193,13 @@ private static boolean isNetworkConnectException(Throwable e) { private static boolean maybeReadTimeOut(Throwable e) { do { if (IOException.class.isInstance(e)) { - String message = e.getMessage().toLowerCase(); - Matcher matcher = READ_TIME_OUT_PATTERN.matcher(message); - if(matcher.find()) { - return true; - } + String message = e.getMessage(); + if (message != null) { + Matcher matcher = READ_TIME_OUT_PATTERN.matcher(message.toLowerCase()); + if(matcher.find()) { + return true; + } + } } e = e.getCause(); } while (e != null);