mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Change Router to do reflective setAccessible() calls itself
This change moves the reflective setAccessible() calls on the request component methods (needed so that they can be invoked reflectively from RequestHandler) to within Router itself, eliminating the need to manually call this from each Servlet class and then pass in the resulting Method objects. Instead, we just pass in the request component class and let Router do the rest. Old comments say that cross-package reflection is not allowed on AppEngine, but while it's quite possible this was once the case, I can't reproduce that limitation, and the documentation seems to contradict any such restriction: """ An application is allowed full, unrestricted, reflective access to its own classes. It can query any private members, call the method java.lang.reflect.AccessibleObject.setAccessible(), and read/set private members. """ https://cloud.google.com/appengine/docs/java/runtime#reflection ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138693006
This commit is contained in:
parent
59c213c66f
commit
9122372e38
7 changed files with 34 additions and 87 deletions
|
@ -14,16 +14,11 @@
|
|||
|
||||
package google.registry.module.frontend;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import google.registry.monitoring.metrics.MetricReporter;
|
||||
import google.registry.request.RequestHandler;
|
||||
import google.registry.request.RequestModule;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.Security;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
@ -40,14 +35,7 @@ public final class FrontendServlet extends HttpServlet {
|
|||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
|
||||
private static final RequestHandler<FrontendRequestComponent> requestHandler =
|
||||
RequestHandler.create(FrontendRequestComponent.class, FluentIterable
|
||||
.from(asList(FrontendRequestComponent.class.getMethods()))
|
||||
.transform(new Function<Method, Method>() {
|
||||
@Override
|
||||
public Method apply(Method method) {
|
||||
method.setAccessible(true); // Make App Engine's security manager happy.
|
||||
return method;
|
||||
}}));
|
||||
RequestHandler.create(FrontendRequestComponent.class);
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue