From 2d31b8521d06b4788bdbe526113ab1c639a67569 Mon Sep 17 00:00:00 2001
From: Redkale <22250530@qq.com>
Date: Tue, 3 Apr 2018 16:14:42 +0800
Subject: [PATCH]
---
src/org/redkale/net/http/Rest.java | 12 +++++++++---
src/org/redkale/net/http/RestMapping.java | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/org/redkale/net/http/Rest.java b/src/org/redkale/net/http/Rest.java
index 59748ad03..5dde1ff1e 100644
--- a/src/org/redkale/net/http/Rest.java
+++ b/src/org/redkale/net/http/Rest.java
@@ -782,15 +782,21 @@ public final class Rest {
for (final Method method : serviceType.getMethods()) {
if (Modifier.isStatic(method.getModifiers())) continue;
if (method.isSynthetic()) continue;
- Class[] extypes = method.getExceptionTypes();
- if (extypes.length > 1) continue;
- if (extypes.length == 1 && extypes[0] != IOException.class) continue;
if (EXCLUDERMETHODS.contains(method.getName())) continue;
if ("init".equals(method.getName())) continue;
if ("destroy".equals(method.getName())) continue;
if ("version".equals(method.getName())) continue;
RestMapping[] mappings = method.getAnnotationsByType(RestMapping.class);
+ 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 (controller == null) continue;
if (!controller.automapping() && mappings.length < 1) continue;
boolean ignore = false;
diff --git a/src/org/redkale/net/http/RestMapping.java b/src/org/redkale/net/http/RestMapping.java
index eaa535d66..0b025bb1a 100644
--- a/src/org/redkale/net/http/RestMapping.java
+++ b/src/org/redkale/net/http/RestMapping.java
@@ -10,7 +10,7 @@ import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/**
- * 只能依附在Service实现类的public方法上
+ * 只能依附在Service实现类的public方法上,且方法如果throws只能是IOException
* value默认为"/" + Service的类名去掉Service字样的小写字符串 (如HelloService,的默认路径为/hello)。
*
* 详情见: https://redkale.org