From 9ff6e47bb0a0f279046e5401f700eb4449f53e1c Mon Sep 17 00:00:00 2001 From: Eric Zhao Date: Thu, 19 Sep 2019 09:38:07 +0800 Subject: [PATCH] Add concrete exception message in AsyncEntry#cleanCurrentEntryInLocal (#1047) Signed-off-by: Eric Zhao --- .../main/java/com/alibaba/csp/sentinel/AsyncEntry.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/AsyncEntry.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/AsyncEntry.java index 84b7c7e3..98ccb85a 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/AsyncEntry.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/AsyncEntry.java @@ -52,7 +52,11 @@ public class AsyncEntry extends CtEntry { ((CtEntry)parent).child = null; } } else { - throw new IllegalStateException("Bad async context state"); + String curEntryName = curEntry == null ? "none" + : curEntry.resourceWrapper.getName() + "@" + curEntry.hashCode(); + String msg = String.format("Bad async context state, expected entry: %s, but actual: %s", + getResourceWrapper().getName() + "@" + hashCode(), curEntryName); + throw new IllegalStateException(msg); } } } @@ -74,7 +78,8 @@ public class AsyncEntry extends CtEntry { .setOrigin(context.getOrigin()) .setCurEntry(this); } else { - RecordLog.warn("[AsyncEntry] Duplicate initialize of async context for entry: " + resourceWrapper.getName()); + RecordLog.warn( + "[AsyncEntry] Duplicate initialize of async context for entry: " + resourceWrapper.getName()); } }