You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/12/05 18:33:58 UTC
svn commit: r1643366 - in /tomcat/trunk: java/org/apache/el/lang/
java/org/apache/el/parser/ java/org/apache/el/stream/ test/org/apache/el/
test/org/apache/el/lang/ test/org/apache/el/stream/
Author: markt
Date: Fri Dec 5 17:33:58 2014
New Revision: 1643366
URL: http://svn.apache.org/r1643366
Log:
Part 2 of fix for
https://issues.apache.org/bugzilla/show_bug.cgi?id=57309
Run all the type specific conversions through the ELResolver
Modified:
tomcat/trunk/java/org/apache/el/lang/ELSupport.java
tomcat/trunk/java/org/apache/el/parser/AstAnd.java
tomcat/trunk/java/org/apache/el/parser/AstChoice.java
tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java
tomcat/trunk/java/org/apache/el/parser/AstConcatenation.java
tomcat/trunk/java/org/apache/el/parser/AstEqual.java
tomcat/trunk/java/org/apache/el/parser/AstGreaterThan.java
tomcat/trunk/java/org/apache/el/parser/AstGreaterThanEqual.java
tomcat/trunk/java/org/apache/el/parser/AstLessThan.java
tomcat/trunk/java/org/apache/el/parser/AstLessThanEqual.java
tomcat/trunk/java/org/apache/el/parser/AstNegative.java
tomcat/trunk/java/org/apache/el/parser/AstNot.java
tomcat/trunk/java/org/apache/el/parser/AstNotEqual.java
tomcat/trunk/java/org/apache/el/parser/AstOr.java
tomcat/trunk/java/org/apache/el/stream/Stream.java
tomcat/trunk/test/org/apache/el/TestELEvaluation.java
tomcat/trunk/test/org/apache/el/lang/TestELSupport.java
tomcat/trunk/test/org/apache/el/stream/TestCollectionOperations.java
Modified: tomcat/trunk/java/org/apache/el/lang/ELSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELSupport.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELSupport.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELSupport.java Fri Dec 5 17:33:58 2014
@@ -72,7 +72,7 @@ public class ELSupport {
* Compare two objects, after coercing to the same type if appropriate.
*
* If the objects are identical, or they are equal according to
- * {@link #equals(Object, Object)} then return 0.
+ * {@link #equals(ELContext, Object, Object)} then return 0.
*
* If either object is a BigDecimal, then coerce both to BigDecimal first.
* Similarly for Double(Float), BigInteger, and Long(Integer, Char, Short, Byte).
@@ -91,39 +91,40 @@ public class ELSupport {
* <li>Otherwise null is considered to be lower than anything else.</li>
* </ul>
*
+ * @param ctx the context in which this comparison is taking place
* @param obj0 first object
* @param obj1 second object
* @return -1, 0, or 1 if this object is less than, equal to, or greater than val.
* @throws ELException if neither object is Comparable
* @throws ClassCastException if the objects are not mutually comparable
*/
- public static final int compare(final Object obj0, final Object obj1)
+ public static final int compare(final ELContext ctx, final Object obj0, final Object obj1)
throws ELException {
- if (obj0 == obj1 || equals(obj0, obj1)) {
+ if (obj0 == obj1 || equals(ctx, obj0, obj1)) {
return 0;
}
if (isBigDecimalOp(obj0, obj1)) {
- BigDecimal bd0 = (BigDecimal) coerceToNumber(obj0, BigDecimal.class);
- BigDecimal bd1 = (BigDecimal) coerceToNumber(obj1, BigDecimal.class);
+ BigDecimal bd0 = (BigDecimal) coerceToNumber(ctx, obj0, BigDecimal.class);
+ BigDecimal bd1 = (BigDecimal) coerceToNumber(ctx, obj1, BigDecimal.class);
return bd0.compareTo(bd1);
}
if (isDoubleOp(obj0, obj1)) {
- Double d0 = (Double) coerceToNumber(obj0, Double.class);
- Double d1 = (Double) coerceToNumber(obj1, Double.class);
+ Double d0 = (Double) coerceToNumber(ctx, obj0, Double.class);
+ Double d1 = (Double) coerceToNumber(ctx, obj1, Double.class);
return d0.compareTo(d1);
}
if (isBigIntegerOp(obj0, obj1)) {
- BigInteger bi0 = (BigInteger) coerceToNumber(obj0, BigInteger.class);
- BigInteger bi1 = (BigInteger) coerceToNumber(obj1, BigInteger.class);
+ BigInteger bi0 = (BigInteger) coerceToNumber(ctx, obj0, BigInteger.class);
+ BigInteger bi1 = (BigInteger) coerceToNumber(ctx, obj1, BigInteger.class);
return bi0.compareTo(bi1);
}
if (isLongOp(obj0, obj1)) {
- Long l0 = (Long) coerceToNumber(obj0, Long.class);
- Long l1 = (Long) coerceToNumber(obj1, Long.class);
+ Long l0 = (Long) coerceToNumber(ctx, obj0, Long.class);
+ Long l1 = (Long) coerceToNumber(ctx, obj1, Long.class);
return l0.compareTo(l1);
}
if (obj0 instanceof String || obj1 instanceof String) {
- return coerceToString(obj0).compareTo(coerceToString(obj1));
+ return coerceToString(ctx, obj0).compareTo(coerceToString(ctx, obj1));
}
if (obj0 instanceof Comparable<?>) {
@SuppressWarnings("unchecked") // checked above
@@ -147,41 +148,42 @@ public class ELSupport {
* Similarly for Enum, String, BigDecimal, Double(Float), Long(Integer, Short, Byte, Character)
* Otherwise default to using Object.equals().
*
+ * @param ctx the context in which this equality test is taking place
* @param obj0 the first object
* @param obj1 the second object
* @return true if the objects are equal
* @throws ELException if one of the coercion fails
*/
- public static final boolean equals(final Object obj0, final Object obj1)
+ public static final boolean equals(final ELContext ctx, final Object obj0, final Object obj1)
throws ELException {
if (obj0 == obj1) {
return true;
} else if (obj0 == null || obj1 == null) {
return false;
} else if (isBigDecimalOp(obj0, obj1)) {
- BigDecimal bd0 = (BigDecimal) coerceToNumber(obj0, BigDecimal.class);
- BigDecimal bd1 = (BigDecimal) coerceToNumber(obj1, BigDecimal.class);
+ BigDecimal bd0 = (BigDecimal) coerceToNumber(ctx, obj0, BigDecimal.class);
+ BigDecimal bd1 = (BigDecimal) coerceToNumber(ctx, obj1, BigDecimal.class);
return bd0.equals(bd1);
} else if (isDoubleOp(obj0, obj1)) {
- Double d0 = (Double) coerceToNumber(obj0, Double.class);
- Double d1 = (Double) coerceToNumber(obj1, Double.class);
+ Double d0 = (Double) coerceToNumber(ctx, obj0, Double.class);
+ Double d1 = (Double) coerceToNumber(ctx, obj1, Double.class);
return d0.equals(d1);
} else if (isBigIntegerOp(obj0, obj1)) {
- BigInteger bi0 = (BigInteger) coerceToNumber(obj0, BigInteger.class);
- BigInteger bi1 = (BigInteger) coerceToNumber(obj1, BigInteger.class);
+ BigInteger bi0 = (BigInteger) coerceToNumber(ctx, obj0, BigInteger.class);
+ BigInteger bi1 = (BigInteger) coerceToNumber(ctx, obj1, BigInteger.class);
return bi0.equals(bi1);
} else if (isLongOp(obj0, obj1)) {
- Long l0 = (Long) coerceToNumber(obj0, Long.class);
- Long l1 = (Long) coerceToNumber(obj1, Long.class);
+ Long l0 = (Long) coerceToNumber(ctx, obj0, Long.class);
+ Long l1 = (Long) coerceToNumber(ctx, obj1, Long.class);
return l0.equals(l1);
} else if (obj0 instanceof Boolean || obj1 instanceof Boolean) {
- return coerceToBoolean(obj0, false).equals(coerceToBoolean(obj1, false));
+ return coerceToBoolean(ctx, obj0, false).equals(coerceToBoolean(ctx, obj1, false));
} else if (obj0.getClass().isEnum()) {
- return obj0.equals(coerceToEnum(obj1, obj0.getClass()));
+ return obj0.equals(coerceToEnum(ctx, obj1, obj0.getClass()));
} else if (obj1.getClass().isEnum()) {
- return obj1.equals(coerceToEnum(obj0, obj1.getClass()));
+ return obj1.equals(coerceToEnum(ctx, obj0, obj1.getClass()));
} else if (obj0 instanceof String || obj1 instanceof String) {
- int lexCompare = coerceToString(obj0).compareTo(coerceToString(obj1));
+ int lexCompare = coerceToString(ctx, obj0).compareTo(coerceToString(ctx, obj1));
return (lexCompare == 0) ? true : false;
} else {
return obj0.equals(obj1);
@@ -192,8 +194,21 @@ public class ELSupport {
// keeps them all in one place. There might be a neater / better solution
// but I couldn't find it
@SuppressWarnings("unchecked")
- public static final Enum<?> coerceToEnum(final Object obj,
+ public static final Enum<?> coerceToEnum(final ELContext ctx, final Object obj,
@SuppressWarnings("rawtypes") Class type) {
+
+ if (ctx != null) {
+ boolean originalIsPropertyResolved = ctx.isPropertyResolved();
+ try {
+ Object result = ctx.getELResolver().convertToType(ctx, obj, type);
+ if (ctx.isPropertyResolved()) {
+ return (Enum<?>) result;
+ }
+ } finally {
+ ctx.setPropertyResolved(originalIsPropertyResolved);
+ }
+ }
+
if (obj == null || "".equals(obj)) {
return null;
}
@@ -219,15 +234,28 @@ public class ELSupport {
/**
* Convert an object to Boolean.
* Null and empty string are false.
+ * @param ctx the context in which this conversion is taking place
* @param obj the object to convert
* @param primitive is the target a primitive in which case coercion to null
* is not permitted
* @return the Boolean value of the object
* @throws ELException if object is not Boolean or String
*/
- public static final Boolean coerceToBoolean(final Object obj,
+ public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj,
boolean primitive) throws ELException {
+ if (ctx != null) {
+ boolean originalIsPropertyResolved = ctx.isPropertyResolved();
+ try {
+ Object result = ctx.getELResolver().convertToType(ctx, obj, Boolean.class);
+ if (ctx.isPropertyResolved()) {
+ return (Boolean) result;
+ }
+ } finally {
+ ctx.setPropertyResolved(originalIsPropertyResolved);
+ }
+ }
+
if (!COERCE_TO_ZERO && !primitive) {
if (obj == null) {
return null;
@@ -248,8 +276,21 @@ public class ELSupport {
obj, obj.getClass(), Boolean.class));
}
- private static final Character coerceToCharacter(final Object obj)
+ private static final Character coerceToCharacter(final ELContext ctx, final Object obj)
throws ELException {
+
+ if (ctx != null) {
+ boolean originalIsPropertyResolved = ctx.isPropertyResolved();
+ try {
+ Object result = ctx.getELResolver().convertToType(ctx, obj, Character.class);
+ if (ctx.isPropertyResolved()) {
+ return (Character) result;
+ }
+ } finally {
+ ctx.setPropertyResolved(originalIsPropertyResolved);
+ }
+ }
+
if (obj == null || "".equals(obj)) {
return Character.valueOf((char) 0);
}
@@ -314,9 +355,21 @@ public class ELSupport {
number, number.getClass(), type));
}
- public static final Number coerceToNumber(final Object obj,
+ public static final Number coerceToNumber(final ELContext ctx, final Object obj,
final Class<?> type) throws ELException {
+ if (ctx != null) {
+ boolean originalIsPropertyResolved = ctx.isPropertyResolved();
+ try {
+ Object result = ctx.getELResolver().convertToType(ctx, obj, type);
+ if (ctx.isPropertyResolved()) {
+ return (Number) result;
+ }
+ } finally {
+ ctx.setPropertyResolved(originalIsPropertyResolved);
+ }
+ }
+
if (!COERCE_TO_ZERO) {
if (obj == null && !type.isPrimitive()) {
return null;
@@ -415,10 +468,24 @@ public class ELSupport {
/**
* Coerce an object to a string.
+ * @param ctx the context in which this conversion is taking place
* @param obj the object to convert
* @return the String value of the object
*/
- public static final String coerceToString(final Object obj) {
+ public static final String coerceToString(final ELContext ctx, final Object obj) {
+
+ if (ctx != null) {
+ boolean originalIsPropertyResolved = ctx.isPropertyResolved();
+ try {
+ Object result = ctx.getELResolver().convertToType(ctx, obj, String.class);
+ if (ctx.isPropertyResolved()) {
+ return (String) result;
+ }
+ } finally {
+ ctx.setPropertyResolved(originalIsPropertyResolved);
+ }
+ }
+
if (obj == null) {
return "";
} else if (obj instanceof String) {
@@ -458,19 +525,19 @@ public class ELSupport {
}
if (String.class.equals(type)) {
- return coerceToString(obj);
+ return coerceToString(ctx, obj);
}
if (ELArithmetic.isNumberType(type)) {
- return coerceToNumber(obj, type);
+ return coerceToNumber(ctx, obj, type);
}
if (Character.class.equals(type) || Character.TYPE == type) {
- return coerceToCharacter(obj);
+ return coerceToCharacter(ctx, obj);
}
if (Boolean.class.equals(type) || Boolean.TYPE == type) {
- return coerceToBoolean(obj, Boolean.TYPE == type);
+ return coerceToBoolean(ctx, obj, Boolean.TYPE == type);
}
if (type.isEnum()) {
- return coerceToEnum(obj, type);
+ return coerceToEnum(ctx, obj, type);
}
// new to spec
Modified: tomcat/trunk/java/org/apache/el/parser/AstAnd.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstAnd.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstAnd.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstAnd.java Fri Dec 5 17:33:58 2014
@@ -35,12 +35,12 @@ public final class AstAnd extends Boolea
public Object getValue(EvaluationContext ctx)
throws ELException {
Object obj = children[0].getValue(ctx);
- Boolean b = coerceToBoolean(obj, true);
+ Boolean b = coerceToBoolean(ctx, obj, true);
if (!b.booleanValue()) {
return b;
}
obj = children[1].getValue(ctx);
- b = coerceToBoolean(obj, true);
+ b = coerceToBoolean(ctx, obj, true);
return b;
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstChoice.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstChoice.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstChoice.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstChoice.java Fri Dec 5 17:33:58 2014
@@ -42,7 +42,7 @@ public final class AstChoice extends Sim
public Object getValue(EvaluationContext ctx)
throws ELException {
Object obj0 = this.children[0].getValue(ctx);
- Boolean b0 = coerceToBoolean(obj0, true);
+ Boolean b0 = coerceToBoolean(ctx, obj0, true);
return this.children[((b0.booleanValue() ? 1 : 2))].getValue(ctx);
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java Fri Dec 5 17:33:58 2014
@@ -48,7 +48,7 @@ public final class AstCompositeExpressio
for (int i = 0; i < this.children.length; i++) {
obj = this.children[i].getValue(ctx);
if (obj != null) {
- sb.append(ELSupport.coerceToString(obj));
+ sb.append(ELSupport.coerceToString(ctx, obj));
}
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstConcatenation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstConcatenation.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstConcatenation.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstConcatenation.java Fri Dec 5 17:33:58 2014
@@ -31,8 +31,8 @@ public class AstConcatenation extends Si
@Override
public Object getValue(EvaluationContext ctx) throws ELException {
// Coerce the two child nodes to string and then concatenate
- String s1 = coerceToString(children[0].getValue(ctx));
- String s2 = coerceToString(children[1].getValue(ctx));
+ String s1 = coerceToString(ctx, children[0].getValue(ctx));
+ String s2 = coerceToString(ctx, children[1].getValue(ctx));
return s1 + s2;
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstEqual.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstEqual.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstEqual.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstEqual.java Fri Dec 5 17:33:58 2014
@@ -36,6 +36,6 @@ public final class AstEqual extends Bool
throws ELException {
Object obj0 = this.children[0].getValue(ctx);
Object obj1 = this.children[1].getValue(ctx);
- return Boolean.valueOf(equals(obj0, obj1));
+ return Boolean.valueOf(equals(ctx, obj0, obj1));
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstGreaterThan.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstGreaterThan.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstGreaterThan.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstGreaterThan.java Fri Dec 5 17:33:58 2014
@@ -42,6 +42,6 @@ public final class AstGreaterThan extend
if (obj1 == null) {
return Boolean.FALSE;
}
- return (compare(obj0, obj1) > 0) ? Boolean.TRUE : Boolean.FALSE;
+ return (compare(ctx, obj0, obj1) > 0) ? Boolean.TRUE : Boolean.FALSE;
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstGreaterThanEqual.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstGreaterThanEqual.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstGreaterThanEqual.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstGreaterThanEqual.java Fri Dec 5 17:33:58 2014
@@ -42,6 +42,6 @@ public final class AstGreaterThanEqual e
if (obj0 == null || obj1 == null) {
return Boolean.FALSE;
}
- return (compare(obj0, obj1) >= 0) ? Boolean.TRUE : Boolean.FALSE;
+ return (compare(ctx, obj0, obj1) >= 0) ? Boolean.TRUE : Boolean.FALSE;
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstLessThan.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLessThan.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstLessThan.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLessThan.java Fri Dec 5 17:33:58 2014
@@ -42,6 +42,6 @@ public final class AstLessThan extends B
if (obj1 == null) {
return Boolean.FALSE;
}
- return (compare(obj0, obj1) < 0) ? Boolean.TRUE : Boolean.FALSE;
+ return (compare(ctx, obj0, obj1) < 0) ? Boolean.TRUE : Boolean.FALSE;
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstLessThanEqual.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLessThanEqual.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstLessThanEqual.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLessThanEqual.java Fri Dec 5 17:33:58 2014
@@ -42,6 +42,6 @@ public final class AstLessThanEqual exte
if (obj0 == null || obj1 == null) {
return Boolean.FALSE;
}
- return (compare(obj0, obj1) <= 0) ? Boolean.TRUE : Boolean.FALSE;
+ return (compare(ctx, obj0, obj1) <= 0) ? Boolean.TRUE : Boolean.FALSE;
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstNegative.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstNegative.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstNegative.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstNegative.java Fri Dec 5 17:33:58 2014
@@ -78,7 +78,7 @@ public final class AstNegative extends S
if (obj instanceof Byte) {
return Byte.valueOf((byte) -((Byte) obj).byteValue());
}
- Long num = (Long) coerceToNumber(obj, Long.class);
+ Long num = (Long) coerceToNumber(ctx, obj, Long.class);
return Long.valueOf(-num.longValue());
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstNot.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstNot.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstNot.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstNot.java Fri Dec 5 17:33:58 2014
@@ -41,7 +41,7 @@ public final class AstNot extends Simple
public Object getValue(EvaluationContext ctx)
throws ELException {
Object obj = this.children[0].getValue(ctx);
- Boolean b = coerceToBoolean(obj, true);
+ Boolean b = coerceToBoolean(ctx, obj, true);
return Boolean.valueOf(!b.booleanValue());
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstNotEqual.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstNotEqual.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstNotEqual.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstNotEqual.java Fri Dec 5 17:33:58 2014
@@ -36,6 +36,6 @@ public final class AstNotEqual extends B
throws ELException {
Object obj0 = this.children[0].getValue(ctx);
Object obj1 = this.children[1].getValue(ctx);
- return Boolean.valueOf(!equals(obj0, obj1));
+ return Boolean.valueOf(!equals(ctx, obj0, obj1));
}
}
Modified: tomcat/trunk/java/org/apache/el/parser/AstOr.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstOr.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstOr.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstOr.java Fri Dec 5 17:33:58 2014
@@ -35,12 +35,12 @@ public final class AstOr extends Boolean
public Object getValue(EvaluationContext ctx)
throws ELException {
Object obj = this.children[0].getValue(ctx);
- Boolean b = coerceToBoolean(obj, true);
+ Boolean b = coerceToBoolean(ctx, obj, true);
if (b.booleanValue()) {
return b;
}
obj = this.children[1].getValue(ctx);
- b = coerceToBoolean(obj, true);
+ b = coerceToBoolean(ctx, obj, true);
return b;
}
}
Modified: tomcat/trunk/java/org/apache/el/stream/Stream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/stream/Stream.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/stream/Stream.java (original)
+++ tomcat/trunk/java/org/apache/el/stream/Stream.java Fri Dec 5 17:33:58 2014
@@ -48,7 +48,7 @@ public class Stream {
protected void findNext() {
while (iterator.hasNext()) {
Object obj = iterator.next();
- if (ELSupport.coerceToBoolean(le.invoke(obj),
+ if (ELSupport.coerceToBoolean(null, le.invoke(obj),
true).booleanValue()) {
next = obj;
foundNext = true;
@@ -450,10 +450,10 @@ public class Stream {
while (iterator.hasNext()) {
Object obj = iterator.next();
- if (isMax && ELSupport.coerceToNumber(le.invoke(obj, result),
+ if (isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result),
Integer.class).intValue() > 0) {
result = obj;
- } else if (!isMax && ELSupport.coerceToNumber(le.invoke(obj, result),
+ } else if (!isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result),
Integer.class).intValue() < 0) {
result = obj;
}
@@ -479,7 +479,7 @@ public class Stream {
@Override
public int compare(Object o1, Object o2) {
return ELSupport.coerceToNumber(
- le.invoke(o1, o2), Integer.class).intValue();
+ null, le.invoke(o1, o2), Integer.class).intValue();
}
}
Modified: tomcat/trunk/test/org/apache/el/TestELEvaluation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELEvaluation.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestELEvaluation.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELEvaluation.java Fri Dec 5 17:33:58 2014
@@ -170,8 +170,8 @@ public class TestELEvaluation {
}
private void compareBoth(String msg, int expected, Object o1, Object o2){
- int i1 = ELSupport.compare(o1, o2);
- int i2 = ELSupport.compare(o2, o1);
+ int i1 = ELSupport.compare(null, o1, o2);
+ int i2 = ELSupport.compare(null, o2, o1);
assertEquals(msg,expected, i1);
assertEquals(msg,expected, -i2);
}
Modified: tomcat/trunk/test/org/apache/el/lang/TestELSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/lang/TestELSupport.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/lang/TestELSupport.java (original)
+++ tomcat/trunk/test/org/apache/el/lang/TestELSupport.java Fri Dec 5 17:33:58 2014
@@ -33,7 +33,7 @@ import org.junit.Test;
public class TestELSupport {
@Test
public void testEquals() {
- assertTrue(ELSupport.equals("01", Long.valueOf(1)));
+ assertTrue(ELSupport.equals(null, "01", Long.valueOf(1)));
}
@Test
@@ -95,7 +95,7 @@ public class TestELSupport {
public void testCoerceEnumAToEnumA() {
Object output = null;
try {
- output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumA.class);
+ output = ELSupport.coerceToEnum(null, TestEnumA.VALA1, TestEnumA.class);
} finally {
assertEquals(TestEnumA.VALA1, output);
}
@@ -105,7 +105,7 @@ public class TestELSupport {
public void testCoerceEnumAToEnumB() {
Object output = null;
try {
- output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumB.class);
+ output = ELSupport.coerceToEnum(null, TestEnumA.VALA1, TestEnumB.class);
} catch (ELException ele) {
// Ignore
}
@@ -116,7 +116,7 @@ public class TestELSupport {
public void testCoerceEnumAToEnumC() {
Object output = null;
try {
- output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumC.class);
+ output = ELSupport.coerceToEnum(null, TestEnumA.VALA1, TestEnumC.class);
} catch (ELException ele) {
// Ignore
}
@@ -243,31 +243,31 @@ public class TestELSupport {
@Test
public void testCoerceToNumber01() {
Object result = ELSupport.coerceToNumber(
- (Object) null, Integer.class);
+ null, (Object) null, Integer.class);
Assert.assertNull("Resut: " + result, result);
}
@Test
public void testCoerceToNumber02() {
Object result = ELSupport.coerceToNumber(
- (Object) null, int.class);
+ null, (Object) null, int.class);
Assert.assertEquals(Integer.valueOf(0), result);
}
@Test
public void testCoerceToBoolean01() {
- Object result = ELSupport.coerceToBoolean(null, true);
+ Object result = ELSupport.coerceToBoolean(null, null, true);
Assert.assertEquals(Boolean.FALSE, result);
}
@Test
public void testCoerceToBoolean02() {
- Object result = ELSupport.coerceToBoolean(null, false);
+ Object result = ELSupport.coerceToBoolean(null, null, false);
Assert.assertNull("Resut: " + result, result);
}
private static void testIsSame(Object value) {
- assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
+ assertEquals(value, ELSupport.coerceToNumber(null, value, value.getClass()));
}
private static enum TestEnumA {
Modified: tomcat/trunk/test/org/apache/el/stream/TestCollectionOperations.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/stream/TestCollectionOperations.java?rev=1643366&r1=1643365&r2=1643366&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/stream/TestCollectionOperations.java (original)
+++ tomcat/trunk/test/org/apache/el/stream/TestCollectionOperations.java Fri Dec 5 17:33:58 2014
@@ -505,7 +505,7 @@ public class TestCollectionOperations {
Number average = (Number) ((Optional) result).get();
Assert.assertTrue("Result: " + average.toString(),
- ELSupport.equals(Long.valueOf(3), average));
+ ELSupport.equals(null, Long.valueOf(3), average));
}
@@ -519,7 +519,7 @@ public class TestCollectionOperations {
Number average = (Number) ((Optional) result).get();
Assert.assertTrue("Result: " + average.toString(),
- ELSupport.equals(Double.valueOf(3.5), average));
+ ELSupport.equals(null, Double.valueOf(3.5), average));
}
@@ -578,7 +578,7 @@ public class TestCollectionOperations {
Object.class);
Assert.assertTrue("Result: " + result.toString(),
- ELSupport.equals(Long.valueOf(15), result));
+ ELSupport.equals(null, Long.valueOf(15), result));
}
@@ -591,7 +591,7 @@ public class TestCollectionOperations {
Object.class);
Assert.assertTrue("Result: " + result.toString(),
- ELSupport.equals(Long.valueOf(0), result));
+ ELSupport.equals(null, Long.valueOf(0), result));
}
@@ -604,7 +604,7 @@ public class TestCollectionOperations {
Object.class);
Assert.assertTrue("Result: " + result.toString(),
- ELSupport.equals(Long.valueOf(5), result));
+ ELSupport.equals(null, Long.valueOf(5), result));
}
@@ -617,7 +617,7 @@ public class TestCollectionOperations {
Object.class);
Assert.assertTrue("Result: " + result.toString(),
- ELSupport.equals(Long.valueOf(0), result));
+ ELSupport.equals(null, Long.valueOf(0), result));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org