From cfecfabc92db274731d265cf176327b41f237d8c Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Mon, 20 Aug 2018 17:28:34 +0800 Subject: [PATCH] =?UTF-8?q?createRestServlet=E5=85=BC=E5=AE=B9throws=20IOE?= =?UTF-8?q?xception=E5=92=8CRuntimeException=E7=9A=84=E5=AD=90=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/net/http/Rest.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/org/redkale/net/http/Rest.java b/src/org/redkale/net/http/Rest.java index 7b1940f53..8d11794a4 100644 --- a/src/org/redkale/net/http/Rest.java +++ b/src/org/redkale/net/http/Rest.java @@ -750,13 +750,12 @@ public final class Rest { if (ignore) continue; Class[] extypes = method.getExceptionTypes(); - if (extypes.length > 1) { - if (mappings != null && mappings.length > 0) throw new RuntimeException("@" + RestMapping.class.getSimpleName() + " only for method with throws IOException"); - continue; - } - if (extypes.length == 1 && extypes[0] != IOException.class) { - if (mappings != null && mappings.length > 0) throw new RuntimeException("@" + RestMapping.class.getSimpleName() + " only for method with throws IOException"); - continue; + if (extypes.length > 0) { + for (Class exp : extypes) { + if (!RuntimeException.class.isAssignableFrom(exp) && !IOException.class.isAssignableFrom(exp)) { + throw new RuntimeException("@" + RestMapping.class.getSimpleName() + " only for method(" + method + ") with throws IOException"); + } + } } paramtypes.add(TypeToken.getGenericType(method.getGenericParameterTypes(), serviceType)); if (mappings.length == 0) { //没有Mapping,设置一个默认值