mirror of
https://github.com/google/nomulus
synced 2026-01-09 23:47:49 +00:00
Make Router reject classes with no @Action-returning methods
This provides a safeguard against using TypeInstantiator to resolve the component class, where if resolution is done incorrectly, you end up with java.lang.Object. Formerly, that would have "succeeded" in generating a Router for Object, which of course has no methods that return @Action classes. Such a router is pretty useless, so it's better to make Router stricter and have it fail if you give it such a class by accident. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148353224
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
package google.registry.request;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
@@ -47,6 +48,8 @@ final class Router {
|
||||
|
||||
private Router(Class<?> componentClass) {
|
||||
this.routes = extractRoutesFromComponent(componentClass);
|
||||
checkArgument(
|
||||
!this.routes.isEmpty(), "No routes found for class: %s", componentClass.getCanonicalName());
|
||||
}
|
||||
|
||||
/** Returns the appropriate action route for a request. */
|
||||
|
||||
Reference in New Issue
Block a user