You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2015/02/12 17:26:03 UTC
svn commit: r1659304 -
/tomcat/trunk/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
Author: kkolinko
Date: Thu Feb 12 16:26:03 2015
New Revision: 1659304
URL: http://svn.apache.org/r1659304
Log:
Simplify code.
Remove @Deprecate marker added in r895423:
That method is declared by both javax.servlet.jsp.el.FunctionMapper and by javax.el.FunctionMapper.
The javax.el.* one is not deprecated.
Modified:
tomcat/trunk/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
Modified: tomcat/trunk/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java?rev=1659304&r1=1659303&r2=1659304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java Thu Feb 12 16:26:03 2015
@@ -18,16 +18,10 @@
package org.apache.jasper.runtime;
import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import javax.servlet.jsp.el.FunctionMapper;
-import org.apache.jasper.security.SecurityUtil;
-
/**
* Maps EL functions to their Java method counterparts. Keeps the actual Method
* objects protected so that JSP pages can't indirectly do reflection.
@@ -57,25 +51,12 @@ public final class ProtectedFunctionMapp
/**
* Generated Servlet and Tag Handler implementations call this method to
- * retrieve an instance of the ProtectedFunctionMapper. This is necessary
- * since generated code does not have access to create instances of classes
- * in this package.
+ * retrieve an instance of the ProtectedFunctionMapper.
*
* @return A new protected function mapper.
*/
public static ProtectedFunctionMapper getInstance() {
- ProtectedFunctionMapper funcMapper;
- if (SecurityUtil.isPackageProtectionEnabled()) {
- funcMapper = AccessController.doPrivileged(
- new PrivilegedAction<ProtectedFunctionMapper>() {
- @Override
- public ProtectedFunctionMapper run() {
- return new ProtectedFunctionMapper();
- }
- });
- } else {
- funcMapper = new ProtectedFunctionMapper();
- }
+ ProtectedFunctionMapper funcMapper = new ProtectedFunctionMapper();
funcMapper.fnmap = new HashMap<>();
return funcMapper;
}
@@ -104,28 +85,12 @@ public final class ProtectedFunctionMapp
return;
}
java.lang.reflect.Method method;
- if (SecurityUtil.isPackageProtectionEnabled()) {
- try {
- method = AccessController.doPrivileged(
- new PrivilegedExceptionAction<Method>() {
- @Override
- public Method run() throws Exception {
- return c.getDeclaredMethod(methodName, args);
- }
- });
- } catch (PrivilegedActionException ex) {
- throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + ex.getException().getMessage());
- }
- } else {
- try {
- method = c.getDeclaredMethod(methodName, args);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + e.getMessage());
- }
+ try {
+ method = c.getMethod(methodName, args);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Invalid function mapping - no such method: "
+ + e.getMessage());
}
this.fnmap.put(fnQName, method);
@@ -150,46 +115,17 @@ public final class ProtectedFunctionMapp
public static ProtectedFunctionMapper getMapForFunction(String fnQName,
final Class<?> c, final String methodName, final Class<?>[] args) {
java.lang.reflect.Method method = null;
- ProtectedFunctionMapper funcMapper;
- if (SecurityUtil.isPackageProtectionEnabled()) {
- funcMapper = AccessController.doPrivileged(
- new PrivilegedAction<ProtectedFunctionMapper>() {
- @Override
- public ProtectedFunctionMapper run() {
- return new ProtectedFunctionMapper();
- }
- });
- // Skip if null values were passed in. They indicate a function
- // added via a lambda or ImportHandler; nether of which need to be
- // placed in the Map.
- if (fnQName != null) {
- try {
- method = AccessController.doPrivileged(
- new PrivilegedExceptionAction<Method>() {
- @Override
- public Method run() throws Exception {
- return c.getDeclaredMethod(methodName, args);
- }
- });
- } catch (PrivilegedActionException ex) {
- throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + ex.getException().getMessage());
- }
- }
- } else {
- funcMapper = new ProtectedFunctionMapper();
- // Skip if null values were passed in. They indicate a function
- // added via a lambda or ImportHandler; nether of which need to be
- // placed in the Map.
- if (fnQName != null) {
- try {
- method = c.getDeclaredMethod(methodName, args);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + e.getMessage());
- }
+ ProtectedFunctionMapper funcMapper = new ProtectedFunctionMapper();
+ // Skip if null values were passed in. They indicate a function
+ // added via a lambda or ImportHandler; nether of which need to be
+ // placed in the Map.
+ if (fnQName != null) {
+ try {
+ method = c.getMethod(methodName, args);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Invalid function mapping - no such method: "
+ + e.getMessage());
}
}
funcMapper.theMethod = method;
@@ -207,7 +143,6 @@ public final class ProtectedFunctionMapp
* @return the result of the method mapping. Null means no entry found.
*/
@Override
- @Deprecated
public Method resolveFunction(String prefix, String localName) {
if (this.fnmap != null) {
return this.fnmap.get(prefix + ":" + localName);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org