From 1aa256b26cd44d78f9ca201ca70eac7bcbb46363 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 12 Jul 2016 14:47:47 -0700 Subject: [PATCH] GUACAMOLE-5: Take superclass into account when determining whether a method is a REST method. --- .../guacamole/rest/RESTMethodMatcher.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/RESTMethodMatcher.java b/guacamole/src/main/java/org/apache/guacamole/rest/RESTMethodMatcher.java index 3a862c88d..c80750c40 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/RESTMethodMatcher.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/RESTMethodMatcher.java @@ -88,7 +88,26 @@ public class RESTMethodMatcher extends AbstractMatcher { } - // The method is not an HTTP method + // A method is also REST method if it overrides a REST method within + // the superclass + Class superclass = method.getDeclaringClass().getSuperclass(); + if (superclass != null) { + + // Recheck against identical method within superclass + try { + return isRESTMethod(superclass.getMethod(method.getName(), + method.getParameterTypes())); + } + + // If there is no such method, then this method cannot possibly be + // a REST method + catch (NoSuchMethodException e) { + return false; + } + + } + + // Lacking a superclass, the search stops here - it's not a REST method return false; }