ognl express support get private field. fix #336

This commit is contained in:
hengyunabc 2018-12-03 20:09:37 +08:00
parent e057bc549b
commit e85e952896

View File

@ -5,6 +5,7 @@ import com.taobao.middleware.logger.Logger;
import ognl.ClassResolver; import ognl.ClassResolver;
import ognl.DefaultMemberAccess; import ognl.DefaultMemberAccess;
import ognl.MemberAccess;
import ognl.Ognl; import ognl.Ognl;
import ognl.OgnlContext; import ognl.OgnlContext;
@ -13,7 +14,7 @@ import ognl.OgnlContext;
* @author hengyunabc 2018-10-18 * @author hengyunabc 2018-10-18
*/ */
public class OgnlExpress implements Express { public class OgnlExpress implements Express {
private static final MemberAccess MEMBER_ACCESS = new DefaultMemberAccess(true);
Logger logger = LogUtil.getArthasLogger(); Logger logger = LogUtil.getArthasLogger();
private Object bindObject; private Object bindObject;
@ -27,7 +28,7 @@ public class OgnlExpress implements Express {
context = new OgnlContext(); context = new OgnlContext();
context.setClassResolver(classResolver); context.setClassResolver(classResolver);
// allow private field access // allow private field access
context.setMemberAccess(new DefaultMemberAccess(true)); context.setMemberAccess(MEMBER_ACCESS);
} }
@Override @Override
@ -62,6 +63,8 @@ public class OgnlExpress implements Express {
public Express reset() { public Express reset() {
context.clear(); context.clear();
context.setClassResolver(CustomClassResolver.customClassResolver); context.setClassResolver(CustomClassResolver.customClassResolver);
// allow private field access
context.setMemberAccess(MEMBER_ACCESS);
return this; return this;
} }
} }