From cc2e79fec9f0cbf1c6b21d2b8c4505a97093abc2 Mon Sep 17 00:00:00 2001 From: lowzj Date: Wed, 19 Jun 2019 10:11:34 +0800 Subject: [PATCH] bugfix: fix NPE in FileMd5NotMatchHandler#getMd5FromMeta Signed-off-by: lowzj --- .../supernode/service/repair/BaseClientErrorHandler.java | 2 +- .../supernode/service/repair/FileMd5NotMatchHandler.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/BaseClientErrorHandler.java b/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/BaseClientErrorHandler.java index 82c53acaf..6b5d9a0c3 100644 --- a/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/BaseClientErrorHandler.java +++ b/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/BaseClientErrorHandler.java @@ -73,7 +73,7 @@ boolean isInvalidInfo(ClientErrorInfo info) { } private void removeTask(String taskId) { - if (StringUtils.isNoneBlank(taskId)) { + if (StringUtils.isNotBlank(taskId)) { remover.add(taskId, true); } } diff --git a/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/FileMd5NotMatchHandler.java b/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/FileMd5NotMatchHandler.java index 511d770b1..6d3c01929 100644 --- a/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/FileMd5NotMatchHandler.java +++ b/src/supernode/src/main/java/com/dragonflyoss/dragonfly/supernode/service/repair/FileMd5NotMatchHandler.java @@ -129,6 +129,9 @@ private String getMd5FromMeta(String taskId, String range) { return null; } List pieceMd5s = fileMetaDataService.readPieceMd5(taskId, meta.getRealMd5()); + if (pieceMd5s == null) { + return null; + } return pieceMd5s.size() > pieceNum ? pieceMd5s.get(pieceNum) : null; }