Skip to content

Commit

Permalink
Bumped up ognl dependency and PMD
Browse files Browse the repository at this point in the history
  • Loading branch information
elecharny committed Sep 10, 2024
1 parent e3dc20b commit ac9ce3f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public final void setAttribute(Attribute attribute) throws AttributeNotFoundExce
try {
PropertyEditor e = getPropertyEditor(getParent(aname).getClass(), pdesc.getName(), pdesc.getPropertyType());
e.setAsText((String) avalue);
OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(source);
ctx.setTypeConverter(typeConverter);

OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(source, null, typeConverter);
Ognl.setValue(aname, ctx, source, e.getValue());
} catch (Exception e) {
throwMBeanException(e);
Expand Down Expand Up @@ -643,8 +643,7 @@ private Class<?> getAttributeClass(String signature) throws ClassNotFoundExcepti

private Object getAttribute(Object object, String fqan, Class<?> attrType) throws OgnlException {
Object property;
OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(object);
ctx.setTypeConverter(new OgnlTypeConverter());
OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(object, null, new OgnlTypeConverter());
if (attrType == null) {
property = Ognl.getValue(fqan, ctx, object);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package org.apache.mina.integration.ognl;

import java.util.Map;

import ognl.ObjectPropertyAccessor;
import ognl.OgnlContext;
import ognl.OgnlException;
Expand Down Expand Up @@ -67,7 +65,7 @@ public final boolean hasSetProperty(OgnlContext context, Object target, Object o
}

@Override
public final Object getPossibleProperty(Map context, Object target, String name) throws OgnlException {
public final Object getPossibleProperty(OgnlContext context, Object target, String name) throws OgnlException {
Object answer = getProperty0((OgnlContext) context, target, name);
if (answer == OgnlRuntime.NotFound) {
answer = super.getPossibleProperty(context, target, name);
Expand All @@ -76,7 +74,7 @@ public final Object getPossibleProperty(Map context, Object target, String name)
}

@Override
public final Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException {
public final Object setPossibleProperty(OgnlContext context, Object target, String name, Object value) throws OgnlException {
if (context.containsKey(READ_ONLY_MODE)) {
throw new OgnlException("Expression must be read-only: " + context.get(QUERY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*/
package org.apache.mina.integration.ognl;

import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

import org.apache.mina.core.session.IoSession;
Expand Down Expand Up @@ -108,12 +110,12 @@ public Set<IoSession> find(Iterable<IoSession> sessions) throws OgnlException {
}

Set<IoSession> answer = new LinkedHashSet<>();
Map<Object,Object> values = new HashMap<>();
values.put(AbstractPropertyAccessor.READ_ONLY_MODE, true);
values.put(AbstractPropertyAccessor.QUERY, query);

for (IoSession s : sessions) {
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(s);
context.setTypeConverter(typeConverter);
context.put(AbstractPropertyAccessor.READ_ONLY_MODE, true);
context.put(AbstractPropertyAccessor.QUERY, query);
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(s, null, typeConverter).withValues(values);
Object result = Ognl.getValue(expression, context, s);

if (result instanceof Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.beans.PropertyEditor;
import java.lang.reflect.Member;
import java.util.Map;

import org.apache.mina.integration.beans.PropertyEditorFactory;

Expand Down Expand Up @@ -46,7 +45,7 @@ public class PropertyTypeConverter implements TypeConverter {
*/
@Override
@SuppressWarnings("unchecked")
public Object convertValue(Map ctx, Object target, Member member, String attrName, Object value, Class toType) {
public Object convertValue(OgnlContext ctx, Object target, Member member, String attrName, Object value, Class toType) {
if (value == null) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
<version.junit>4.13.2</version.junit>
<version.jzlib>1.1.3</version.jzlib>
<version.log4j>1.2.17</version.log4j>
<version.ognl>3.3.4</version.ognl>
<version.pmd>7.0.0</version.pmd>
<version.ognl>3.4.3</version.ognl>
<version.pmd>7.5.0</version.pmd>
<version.slf4j.api>1.7.36</version.slf4j.api>
<version.slf4j.reload4j>1.7.36</version.slf4j.reload4j>
<version.slf4j.jcl.over.slf4j>1.7.36</version.slf4j.jcl.over.slf4j>
Expand Down

0 comments on commit ac9ce3f

Please sign in to comment.