JBossWeb SVN: r1640 - sandbox/webapps/src.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2011-01-27 10:24:30 -0500 (Thu, 27 Jan 2011)
New Revision: 1640
Modified:
sandbox/webapps/src/TestAsyncServlet.java
Log:
Example no working with native at TC7.
Modified: sandbox/webapps/src/TestAsyncServlet.java
===================================================================
--- sandbox/webapps/src/TestAsyncServlet.java 2011-01-17 11:21:35 UTC (rev 1639)
+++ sandbox/webapps/src/TestAsyncServlet.java 2011-01-27 15:24:30 UTC (rev 1640)
@@ -45,7 +45,7 @@
// @WebServlet("/TestAsyncServlet")
@WebServlet(urlPatterns = {"/TestAsyncServlet"}, asyncSupported = true)
public class TestAsyncServlet extends HttpServlet {
- public void doPost(HttpServletRequest req, HttpServletResponse res) {
+ public void doGet(HttpServletRequest req, HttpServletResponse res) {
// Servlet Code
// ...........
// Call startAsync
@@ -53,26 +53,31 @@
// Give AsyncContext to the Listener MonListener
context.addListener(new MonListener());
// ...........
+ context.complete();
}
public class MonListener implements AsyncListener {
- public void onComplete(AsyncEvent event) {
+ public void onComplete(AsyncEvent event) throws IOException {
System.out.println("onComplete");
+ event.getAsyncContext().getResponse().getWriter().println("onComplete");
}
- public void onError(AsyncEvent event) {
+ public void onError(AsyncEvent event) throws IOException {
ServletResponse res = event.getSuppliedResponse();
System.out.println("onError: " + res);
+ event.getAsyncContext().getResponse().getWriter().println("onError");
}
- public void onTimeout(AsyncEvent event) {
+ public void onTimeout(AsyncEvent event) throws IOException {
ServletResponse res = event.getSuppliedResponse();
try {
ServletOutputStream os = res.getOutputStream();
System.out.println("onTimeout: " + res);
} catch (Exception e) {
}
+ event.getAsyncContext().getResponse().getWriter().println("onTimeout");
}
- public void onStartAsync(AsyncEvent event) {
+ public void onStartAsync(AsyncEvent event) throws IOException {
System.out.println("onStartAsync");
+ event.getAsyncContext().getResponse().getWriter().println("onStartAsync");
}
}
13 years, 11 months
JBossWeb SVN: r1639 - in branches/2.1.x: java/org/apache/catalina/connector and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-01-17 06:21:35 -0500 (Mon, 17 Jan 2011)
New Revision: 1639
Modified:
branches/2.1.x/java/javax/el/BeanELResolver.java
branches/2.1.x/java/org/apache/catalina/connector/Request.java
branches/2.1.x/java/org/apache/el/lang/ExpressionBuilder.java
branches/2.1.x/java/org/apache/el/util/ConcurrentCache.java
branches/2.1.x/webapps/docs/changelog.xml
Log:
- JBWEB-148: Possible NPE on set/removeAttribute.
- JBWEB-185: Fix thread safety in two EL caches.
Modified: branches/2.1.x/java/javax/el/BeanELResolver.java
===================================================================
--- branches/2.1.x/java/javax/el/BeanELResolver.java 2011-01-07 14:17:42 UTC (rev 1638)
+++ branches/2.1.x/java/javax/el/BeanELResolver.java 2011-01-17 11:21:35 UTC (rev 1639)
@@ -25,6 +25,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -34,10 +36,29 @@
public class BeanELResolver extends ELResolver {
+ private static final int CACHE_SIZE;
+ private static final String CACHE_SIZE_PROP =
+ "org.apache.el.BeanELResolver.CACHE_SIZE";
+
+ static {
+ if (System.getSecurityManager() == null) {
+ CACHE_SIZE = Integer.parseInt(
+ System.getProperty(CACHE_SIZE_PROP, "1000"));
+ } else {
+ CACHE_SIZE = AccessController.doPrivileged(
+ new PrivilegedAction<Integer>() {
+ public Integer run() {
+ return Integer.valueOf(
+ System.getProperty(CACHE_SIZE_PROP, "1000"));
+ }
+ }).intValue();
+ }
+ }
+
private final boolean readOnly;
- private final ConcurrentCache<String, BeanProperties> cache = new ConcurrentCache<String, BeanProperties>(
- 1000);
+ private final ConcurrentCache<String, BeanProperties> cache =
+ new ConcurrentCache<String, BeanProperties>(CACHE_SIZE);
public BeanELResolver() {
this.readOnly = false;
@@ -324,7 +345,9 @@
public V get(K key) {
V value = this.eden.get(key);
if (value == null) {
- value = this.longterm.get(key);
+ synchronized (longterm) {
+ value = this.longterm.get(key);
+ }
if (value != null) {
this.eden.put(key, value);
}
@@ -334,11 +357,12 @@
public void put(K key, V value) {
if (this.eden.size() >= this.size) {
- this.longterm.putAll(this.eden);
+ synchronized (longterm) {
+ this.longterm.putAll(this.eden);
+ }
this.eden.clear();
}
this.eden.put(key, value);
}
-
}
}
Modified: branches/2.1.x/java/org/apache/catalina/connector/Request.java
===================================================================
--- branches/2.1.x/java/org/apache/catalina/connector/Request.java 2011-01-07 14:17:42 UTC (rev 1638)
+++ branches/2.1.x/java/org/apache/catalina/connector/Request.java 2011-01-17 11:21:35 UTC (rev 1639)
@@ -1369,6 +1369,9 @@
return;
}
+ if (context == null)
+ return;
+
// Notify interested application event listeners
Object listeners[] = context.getApplicationEventListeners();
if ((listeners == null) || (listeners.length == 0))
@@ -1439,6 +1442,9 @@
coyoteRequest.setAttribute(name, value);
}
+ if (context == null)
+ return;
+
// Notify interested application event listeners
Object listeners[] = context.getApplicationEventListeners();
if ((listeners == null) || (listeners.length == 0))
Modified: branches/2.1.x/java/org/apache/el/lang/ExpressionBuilder.java
===================================================================
--- branches/2.1.x/java/org/apache/el/lang/ExpressionBuilder.java 2011-01-07 14:17:42 UTC (rev 1638)
+++ branches/2.1.x/java/org/apache/el/lang/ExpressionBuilder.java 2011-01-17 11:21:35 UTC (rev 1639)
@@ -50,7 +50,7 @@
*/
public final class ExpressionBuilder implements NodeVisitor {
- private static final ConcurrentCache cache = new ConcurrentCache(5000);
+ private static final ConcurrentCache cache = new ConcurrentCache(10000);
private FunctionMapper fnMapper;
Modified: branches/2.1.x/java/org/apache/el/util/ConcurrentCache.java
===================================================================
--- branches/2.1.x/java/org/apache/el/util/ConcurrentCache.java 2011-01-07 14:17:42 UTC (rev 1638)
+++ branches/2.1.x/java/org/apache/el/util/ConcurrentCache.java 2011-01-17 11:21:35 UTC (rev 1639)
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.el.util;
import java.util.Map;
@@ -6,34 +22,38 @@
public final class ConcurrentCache<K,V> {
- private final int size;
-
- private final Map<K,V> eden;
-
- private final Map<K,V> longterm;
-
- public ConcurrentCache(int size) {
- this.size = size;
- this.eden = new ConcurrentHashMap<K,V>(size);
- this.longterm = new WeakHashMap<K,V>(size);
- }
-
- public V get(K k) {
- V v = this.eden.get(k);
- if (v == null) {
- v = this.longterm.get(k);
- if (v != null) {
- this.eden.put(k, v);
- }
- }
- return v;
- }
-
- public void put(K k, V v) {
- if (this.eden.size() >= size) {
- this.longterm.putAll(this.eden);
- this.eden.clear();
- }
- this.eden.put(k, v);
- }
+ private final int size;
+
+ private final Map<K,V> eden;
+
+ private final Map<K,V> longterm;
+
+ public ConcurrentCache(int size) {
+ this.size = size;
+ this.eden = new ConcurrentHashMap<K,V>(size);
+ this.longterm = new WeakHashMap<K,V>(size);
+ }
+
+ public V get(K k) {
+ V v = this.eden.get(k);
+ if (v == null) {
+ synchronized (longterm) {
+ v = this.longterm.get(k);
+ }
+ if (v != null) {
+ this.eden.put(k, v);
+ }
+ }
+ return v;
+ }
+
+ public void put(K k, V v) {
+ if (this.eden.size() >= size) {
+ synchronized (longterm) {
+ this.longterm.putAll(this.eden);
+ }
+ this.eden.clear();
+ }
+ this.eden.put(k, v);
+ }
}
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2011-01-07 14:17:42 UTC (rev 1638)
+++ branches/2.1.x/webapps/docs/changelog.xml 2011-01-17 11:21:35 UTC (rev 1639)
@@ -16,6 +16,13 @@
<body>
<section name="JBoss Web 2.1.11.GA (remm)">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ <jira>148</jira>: Fix possible NPE on request.set/removeAttribute. (remm)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Coyote">
<changelog>
<fix>
@@ -23,6 +30,14 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <jira>185</jira>: Fix cache thread safety issue for EL expression builder.
+ Patch submitted by Takayoshi Kimura. (remm)
+ </fix>
+ </changelog>
+ </subsection>
</section>
<section name="JBoss Web 2.1.10.GA (remm)">
13 years, 11 months
JBossWeb SVN: r1638 - in trunk: java/org/apache/tomcat/util/http and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-01-07 09:17:42 -0500 (Fri, 07 Jan 2011)
New Revision: 1638
Modified:
trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
trunk/java/org/apache/tomcat/util/http/Cookies.java
trunk/webapps/docs/changelog.xml
Log:
- Improve name only cookies.
- Fix APR getRemoteHost.
Modified: trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2011-01-07 13:59:04 UTC (rev 1637)
+++ trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2011-01-07 14:17:42 UTC (rev 1638)
@@ -1109,6 +1109,10 @@
try {
long sa = Address.get(Socket.APR_REMOTE, socket);
remoteHost = Address.getnameinfo(sa, 0);
+ if (remoteHost == null) {
+ remoteAddr = Address.getip(sa);
+ remoteHost = remoteAddr;
+ }
} catch (Exception e) {
log.warn(sm.getString("http11processor.socket.info"), e);
}
Modified: trunk/java/org/apache/tomcat/util/http/Cookies.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/Cookies.java 2011-01-07 13:59:04 UTC (rev 1637)
+++ trunk/java/org/apache/tomcat/util/http/Cookies.java 2011-01-07 14:17:42 UTC (rev 1638)
@@ -283,7 +283,7 @@
// cookie at the end of the cookie header, so if we
// are past the end of the header, but we have a name
// skip to the name-only part.
- if (pos < end && bytes[pos] == '=') {
+ if (pos < (end - 1) && bytes[pos] == '=') {
// Skip whitespace
do {
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2011-01-07 13:59:04 UTC (rev 1637)
+++ trunk/webapps/docs/changelog.xml 2011-01-07 14:17:42 UTC (rev 1638)
@@ -23,6 +23,12 @@
</subsection>
<subsection name="Coyote">
<changelog>
+ <fix>
+ <bug>49000</bug>: Improve name only cookie handling. (markt)
+ </fix>
+ <fix>
+ <bug>47319</bug>: Fix getRemoteHost() with APR when name cannot be resolved. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
13 years, 11 months
JBossWeb SVN: r1637 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-01-07 08:59:04 -0500 (Fri, 07 Jan 2011)
New Revision: 1637
Modified:
trunk/java/org/apache/el/lang/ELArithmetic.java
trunk/webapps/docs/changelog.xml
Log:
- 50500: Improve EL arithmetic conversions.
Modified: trunk/java/org/apache/el/lang/ELArithmetic.java
===================================================================
--- trunk/java/org/apache/el/lang/ELArithmetic.java 2011-01-06 13:28:45 UTC (rev 1636)
+++ trunk/java/org/apache/el/lang/ELArithmetic.java 2011-01-07 13:59:04 UTC (rev 1637)
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,16 +26,18 @@
/**
* A helper class of Arithmetic defined by the EL Specification
* @author Jacob Hookom [jacob(a)hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
+ * @version $Id$
*/
public abstract class ELArithmetic {
- public final static class BigDecimalDelegate extends ELArithmetic {
+ public static final class BigDecimalDelegate extends ELArithmetic {
+ @Override
protected Number add(Number num0, Number num1) {
return ((BigDecimal) num0).add((BigDecimal) num1);
}
+ @Override
protected Number coerce(Number num) {
if (num instanceof BigDecimal)
return num;
@@ -44,71 +46,86 @@
return new BigDecimal(num.doubleValue());
}
+ @Override
protected Number coerce(String str) {
return new BigDecimal(str);
}
+ @Override
protected Number divide(Number num0, Number num1) {
return ((BigDecimal) num0).divide((BigDecimal) num1,
BigDecimal.ROUND_HALF_UP);
}
+ @Override
protected Number subtract(Number num0, Number num1) {
return ((BigDecimal) num0).subtract((BigDecimal) num1);
}
+ @Override
protected Number mod(Number num0, Number num1) {
return new Double(num0.doubleValue() % num1.doubleValue());
}
+ @Override
protected Number multiply(Number num0, Number num1) {
return ((BigDecimal) num0).multiply((BigDecimal) num1);
}
+ @Override
public boolean matches(Object obj0, Object obj1) {
return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal);
}
}
- public final static class BigIntegerDelegate extends ELArithmetic {
+ public static final class BigIntegerDelegate extends ELArithmetic {
+ @Override
protected Number add(Number num0, Number num1) {
return ((BigInteger) num0).add((BigInteger) num1);
}
+ @Override
protected Number coerce(Number num) {
if (num instanceof BigInteger)
return num;
return new BigInteger(num.toString());
}
+ @Override
protected Number coerce(String str) {
return new BigInteger(str);
}
+ @Override
protected Number divide(Number num0, Number num1) {
return (new BigDecimal((BigInteger) num0)).divide(new BigDecimal((BigInteger) num1), BigDecimal.ROUND_HALF_UP);
}
+ @Override
protected Number multiply(Number num0, Number num1) {
return ((BigInteger) num0).multiply((BigInteger) num1);
}
+ @Override
protected Number mod(Number num0, Number num1) {
return ((BigInteger) num0).mod((BigInteger) num1);
}
+ @Override
protected Number subtract(Number num0, Number num1) {
return ((BigInteger) num0).subtract((BigInteger) num1);
}
+ @Override
public boolean matches(Object obj0, Object obj1) {
return (obj0 instanceof BigInteger || obj1 instanceof BigInteger);
}
}
- public final static class DoubleDelegate extends ELArithmetic {
+ public static final class DoubleDelegate extends ELArithmetic {
+ @Override
protected Number add(Number num0, Number num1) {
// could only be one of these
if (num0 instanceof BigDecimal) {
@@ -119,6 +136,7 @@
return new Double(num0.doubleValue() + num1.doubleValue());
}
+ @Override
protected Number coerce(Number num) {
if (num instanceof Double)
return num;
@@ -127,18 +145,22 @@
return new Double(num.doubleValue());
}
+ @Override
protected Number coerce(String str) {
return new Double(str);
}
+ @Override
protected Number divide(Number num0, Number num1) {
return new Double(num0.doubleValue() / num1.doubleValue());
}
+ @Override
protected Number mod(Number num0, Number num1) {
return new Double(num0.doubleValue() % num1.doubleValue());
}
+ @Override
protected Number subtract(Number num0, Number num1) {
// could only be one of these
if (num0 instanceof BigDecimal) {
@@ -149,6 +171,7 @@
return new Double(num0.doubleValue() - num1.doubleValue());
}
+ @Override
protected Number multiply(Number num0, Number num1) {
// could only be one of these
if (num0 instanceof BigDecimal) {
@@ -159,6 +182,7 @@
return new Double(num0.doubleValue() * num1.doubleValue());
}
+ @Override
public boolean matches(Object obj0, Object obj1) {
return (obj0 instanceof Double
|| obj1 instanceof Double
@@ -170,64 +194,75 @@
}
}
- public final static class LongDelegate extends ELArithmetic {
+ public static final class LongDelegate extends ELArithmetic {
+ @Override
protected Number add(Number num0, Number num1) {
- return new Long(num0.longValue() + num1.longValue());
+ return Long.valueOf(num0.longValue() + num1.longValue());
}
+ @Override
protected Number coerce(Number num) {
if (num instanceof Long)
return num;
- return new Long(num.longValue());
+ return Long.valueOf(num.longValue());
}
+ @Override
protected Number coerce(String str) {
- return new Long(str);
+ return Long.valueOf(str);
}
+ @Override
protected Number divide(Number num0, Number num1) {
- return new Long(num0.longValue() / num1.longValue());
+ return Long.valueOf(num0.longValue() / num1.longValue());
}
+ @Override
protected Number mod(Number num0, Number num1) {
- return new Long(num0.longValue() % num1.longValue());
+ return Long.valueOf(num0.longValue() % num1.longValue());
}
+ @Override
protected Number subtract(Number num0, Number num1) {
- return new Long(num0.longValue() - num1.longValue());
+ return Long.valueOf(num0.longValue() - num1.longValue());
}
+ @Override
protected Number multiply(Number num0, Number num1) {
- return new Long(num0.longValue() * num1.longValue());
+ return Long.valueOf(num0.longValue() * num1.longValue());
}
+ @Override
public boolean matches(Object obj0, Object obj1) {
return (obj0 instanceof Long || obj1 instanceof Long);
}
}
- public final static BigDecimalDelegate BIGDECIMAL = new BigDecimalDelegate();
+ public static final BigDecimalDelegate BIGDECIMAL = new BigDecimalDelegate();
- public final static BigIntegerDelegate BIGINTEGER = new BigIntegerDelegate();
+ public static final BigIntegerDelegate BIGINTEGER = new BigIntegerDelegate();
- public final static DoubleDelegate DOUBLE = new DoubleDelegate();
+ public static final DoubleDelegate DOUBLE = new DoubleDelegate();
- public final static LongDelegate LONG = new LongDelegate();
+ public static final LongDelegate LONG = new LongDelegate();
- private final static Long ZERO = new Long(0);
+ private static final Long ZERO = Long.valueOf(0);
- public final static Number add(final Object obj0, final Object obj1) {
+ public static final Number add(final Object obj0, final Object obj1) {
if (obj0 == null && obj1 == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
final ELArithmetic delegate;
if (BIGDECIMAL.matches(obj0, obj1))
delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
+ else if (DOUBLE.matches(obj0, obj1)) {
+ if (BIGINTEGER.matches(obj0, obj1))
+ delegate = BIGDECIMAL;
+ else
+ delegate = DOUBLE;
+ } else if (BIGINTEGER.matches(obj0, obj1))
delegate = BIGINTEGER;
else
delegate = LONG;
@@ -238,14 +273,14 @@
return delegate.add(num0, num1);
}
- public final static Number mod(final Object obj0, final Object obj1) {
+ public static final Number mod(final Object obj0, final Object obj1) {
if (obj0 == null && obj1 == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
final ELArithmetic delegate;
if (BIGDECIMAL.matches(obj0, obj1))
- delegate = BIGDECIMAL;
+ delegate = DOUBLE;
else if (DOUBLE.matches(obj0, obj1))
delegate = DOUBLE;
else if (BIGINTEGER.matches(obj0, obj1))
@@ -259,18 +294,21 @@
return delegate.mod(num0, num1);
}
- public final static Number subtract(final Object obj0, final Object obj1) {
+ public static final Number subtract(final Object obj0, final Object obj1) {
if (obj0 == null && obj1 == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
final ELArithmetic delegate;
if (BIGDECIMAL.matches(obj0, obj1))
delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
- delegate = BIGINTEGER;
+ else if (DOUBLE.matches(obj0, obj1)) {
+ if (BIGINTEGER.matches(obj0, obj1))
+ delegate = BIGDECIMAL;
+ else
+ delegate = DOUBLE;
+ } else if (BIGINTEGER.matches(obj0, obj1))
+ delegate = BIGINTEGER;
else
delegate = LONG;
@@ -280,7 +318,7 @@
return delegate.subtract(num0, num1);
}
- public final static Number divide(final Object obj0, final Object obj1) {
+ public static final Number divide(final Object obj0, final Object obj1) {
if (obj0 == null && obj1 == null) {
return ZERO;
}
@@ -299,17 +337,20 @@
return delegate.divide(num0, num1);
}
- public final static Number multiply(final Object obj0, final Object obj1) {
+ public static final Number multiply(final Object obj0, final Object obj1) {
if (obj0 == null && obj1 == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
final ELArithmetic delegate;
if (BIGDECIMAL.matches(obj0, obj1))
delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
+ else if (DOUBLE.matches(obj0, obj1)) {
+ if (BIGINTEGER.matches(obj0, obj1))
+ delegate = BIGDECIMAL;
+ else
+ delegate = DOUBLE;
+ } else if (BIGINTEGER.matches(obj0, obj1))
delegate = BIGINTEGER;
else
delegate = LONG;
@@ -320,11 +361,11 @@
return delegate.multiply(num0, num1);
}
- public final static boolean isNumber(final Object obj) {
+ public static final boolean isNumber(final Object obj) {
return (obj != null && isNumberType(obj.getClass()));
}
- public final static boolean isNumberType(final Class<?> type) {
+ public static final boolean isNumberType(final Class<?> type) {
return type == Long.TYPE || type == Double.TYPE ||
type == Byte.TYPE || type == Short.TYPE ||
type == Integer.TYPE || type == Float.TYPE ||
@@ -332,7 +373,7 @@
}
/**
- *
+ *
*/
protected ELArithmetic() {
super();
@@ -349,7 +390,7 @@
protected abstract Number coerce(final Number num);
protected final Number coerce(final Object obj) {
-
+
if (isNumber(obj)) {
return coerce((Number) obj);
}
@@ -361,7 +402,7 @@
}
if (obj instanceof Character) {
- return coerce(new Short((short) ((Character) obj).charValue()));
+ return coerce(Short.valueOf((short) ((Character) obj).charValue()));
}
throw new IllegalArgumentException(MessageFactory.get("error.convert",
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2011-01-06 13:28:45 UTC (rev 1636)
+++ trunk/webapps/docs/changelog.xml 2011-01-07 13:59:04 UTC (rev 1637)
@@ -16,6 +16,24 @@
<body>
+<section name="JBoss Web 7.0.0.Beta2 (remm)">
+ <subsection name="Catalina">
+ <changelog>
+ </changelog>
+ </subsection>
+ <subsection name="Coyote">
+ <changelog>
+ </changelog>
+ </subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <bug>50500</bug>: Improve certain arithmetic conversions in EL. (markt)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 7.0.0.Beta1 (remm)">
<subsection name="Catalina">
<changelog>
13 years, 11 months
JBossWeb SVN: r1636 - sandbox/webapps/src.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2011-01-06 08:28:45 -0500 (Thu, 06 Jan 2011)
New Revision: 1636
Modified:
sandbox/webapps/src/MyCookies.java
Log:
Add a test for colon in cookie.
Modified: sandbox/webapps/src/MyCookies.java
===================================================================
--- sandbox/webapps/src/MyCookies.java 2011-01-06 13:24:52 UTC (rev 1635)
+++ sandbox/webapps/src/MyCookies.java 2011-01-06 13:28:45 UTC (rev 1636)
@@ -92,7 +92,7 @@
/*
* create the name/value pairs
*/
- Test[] mytest = new Test[14];
+ Test[] mytest = new Test[15];
StringBuffer buffer = new StringBuffer();
buffer.append("<xml><name>John Doe</name><age attribute=\"this breaks\">45</age></xml>");
mytest[0] = new Test("xmlCookie",buffer.toString());
@@ -111,6 +111,7 @@
// mytest[12] = new Test("Equal","P=I am = Equal\n...&A=46164");
mytest[12] = new Test("Equal","P=14662+26891+20253+28934+15744+22344+43641+13624+28974+15489+35353+47293+14662+26891+20253+28934+28596+27065+28648+22542&L=60766+6654+19186+43352+58684+61932+37440+23672&A=46164+56607+41861+51054&S=46164+56607+41861+51054&T=23922+55384+5601+51160+38643+36027+49212+16265+61873+55260+16665+53468&X=12795+26412+43746+37688&U=47207+55215+24609+16813+46164+56607+41861+51054&D=36080+20612+7827+5411+35188+54326+19636+46695+27748+646+37165+34626&C=11656+47389+63649+49622+46164+56607+41861+51054&");
mytest[13] = new Test("RH-Test-Cookie" , "testcookie::aftercolon; expires=Fri, 31 Dec 2010 23:59:59 GMT; path=/");
+ mytest[14] = new Test("RH-Test-Cookie2" , "testcookie::aftercolon");
Cookie[] cookies = request.getCookies();
if(cookies != null) {
for(int i=0;i<cookies.length;i++) {
13 years, 11 months
JBossWeb SVN: r1635 - sandbox/webapps/src.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2011-01-06 08:24:52 -0500 (Thu, 06 Jan 2011)
New Revision: 1635
Modified:
sandbox/webapps/src/TestServlet.java
Log:
Arrange the wait on start logic.
Modified: sandbox/webapps/src/TestServlet.java
===================================================================
--- sandbox/webapps/src/TestServlet.java 2011-01-05 22:46:57 UTC (rev 1634)
+++ sandbox/webapps/src/TestServlet.java 2011-01-06 13:24:52 UTC (rev 1635)
@@ -45,8 +45,11 @@
public void init(ServletConfig config) throws ServletException {
String swait = config.getInitParameter("wait");
- Integer iwait = new Integer(swait);
- int wait = iwait.intValue();
+ int wait = 10;
+ if (swait != null) {
+ Integer iwait = new Integer(swait);
+ wait = iwait.intValue();
+ }
Thread me = Thread.currentThread();
try {
me.sleep(wait);
13 years, 11 months
JBossWeb SVN: r1634 - branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727/src/share/classes/org/apache/catalina/authenticator.
by jbossweb-commits@lists.jboss.org
Author: dehort
Date: 2011-01-05 17:46:57 -0500 (Wed, 05 Jan 2011)
New Revision: 1634
Modified:
branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java
Log:
Fixed a bug where after repeated authentication tomcat again sends page with login form instead of protected static resource
[JBPAPP-5727]
Modified: branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java 2011-01-05 22:11:09 UTC (rev 1633)
+++ branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java 2011-01-05 22:46:57 UTC (rev 1634)
@@ -402,12 +402,20 @@
MimeHeaders rmh = request.getCoyoteRequest().getMimeHeaders();
rmh.recycle();
+ boolean cachable = "GET".equalsIgnoreCase(saved.getMethod()) ||
+ "HEAD".equalsIgnoreCase(saved.getMethod());
Iterator names = saved.getHeaderNames();
while (names.hasNext()) {
String name = (String) names.next();
- Iterator values = saved.getHeaderValues(name);
- while (values.hasNext()) {
- rmh.addValue(name).setString( (String)values.next() );
+ // The browser isn't expecting this conditional response now.
+ // Assuming that it can quietly recover from an unexpected 412.
+ // BZ 43687
+ if(!("If-Modified-Since".equalsIgnoreCase(name) ||
+ (cachable && "If-None-Match".equalsIgnoreCase(name)))) {
+ Iterator values = saved.getHeaderValues(name);
+ while (values.hasNext()) {
+ rmh.addValue(name).setString( (String)values.next() );
+ }
}
}
13 years, 11 months
JBossWeb SVN: r1633 - branches.
by jbossweb-commits@lists.jboss.org
Author: dehort
Date: 2011-01-05 17:11:09 -0500 (Wed, 05 Jan 2011)
New Revision: 1633
Added:
branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727/
Log:
Create JBPAPP-5727 patch branch from JBOSSWEB_2_0_0_CP08 tag
Copied: branches/JBOSSWEB_2_0_0_GA_CP08_JBPAPP-5727 (from rev 1632, tags/JBOSSWEB_2_0_0_GA_CP08)
13 years, 11 months
JBossWeb SVN: r1632 - branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/authenticator.
by jbossweb-commits@lists.jboss.org
Author: dehort
Date: 2011-01-05 16:07:08 -0500 (Wed, 05 Jan 2011)
New Revision: 1632
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java
Log:
[JBWEB-119] After repeated authentication tomcat again sends page with login form instead of protected static resource
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java 2011-01-05 17:35:54 UTC (rev 1631)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java 2011-01-05 21:07:08 UTC (rev 1632)
@@ -402,12 +402,20 @@
MimeHeaders rmh = request.getCoyoteRequest().getMimeHeaders();
rmh.recycle();
+ boolean cachable = "GET".equalsIgnoreCase(saved.getMethod()) ||
+ "HEAD".equalsIgnoreCase(saved.getMethod());
Iterator names = saved.getHeaderNames();
while (names.hasNext()) {
String name = (String) names.next();
- Iterator values = saved.getHeaderValues(name);
- while (values.hasNext()) {
- rmh.addValue(name).setString( (String)values.next() );
+ // The browser isn't expecting this conditional response now.
+ // Assuming that it can quietly recover from an unexpected 412.
+ // BZ 43687
+ if(!("If-Modified-Since".equalsIgnoreCase(name) ||
+ (cachable && "If-None-Match".equalsIgnoreCase(name)))) {
+ Iterator values = saved.getHeaderValues(name);
+ while (values.hasNext()) {
+ rmh.addValue(name).setString( (String)values.next() );
+ }
}
}
13 years, 11 months
JBossWeb SVN: r1630 - in branches/3.0.x: java/org/apache/el/util and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-01-04 04:04:39 -0500 (Tue, 04 Jan 2011)
New Revision: 1630
Modified:
branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java
branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java
branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java
branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java
branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java
branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java
branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java
branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java
branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java
branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java
branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties
branches/3.0.x/webapps/docs/changelog.xml
Log:
- Rebase Jasper from the 7 branch's Jasper to pull in all fixes.
Modified: branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java
===================================================================
--- branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -19,6 +19,9 @@
import java.io.StringReader;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.concurrent.ConcurrentHashMap;
import javax.el.ELContext;
import javax.el.ELException;
@@ -50,8 +53,36 @@
*/
public final class ExpressionBuilder implements NodeVisitor {
- private static final ConcurrentCache cache = new ConcurrentCache(5000);
+ private static final int CACHE_SIZE;
+ private static final String CACHE_SIZE_PROP =
+ "org.apache.el.lang.ExpressionBuilder.CACHE_SIZE";
+ static {
+ if (System.getSecurityManager() == null) {
+ CACHE_SIZE = Integer.parseInt(
+ System.getProperty(CACHE_SIZE_PROP, "-1"));
+ } else {
+ CACHE_SIZE = AccessController.doPrivileged(
+ new PrivilegedAction<Integer>() {
+ @Override
+ public Integer run() {
+ return Integer.valueOf(
+ System.getProperty(CACHE_SIZE_PROP, "-1"));
+ }
+ }).intValue();
+ }
+ if (CACHE_SIZE > 0) {
+ unlimitedCache = null;
+ cache = new ConcurrentCache<String, Node>(CACHE_SIZE);
+ } else {
+ cache = null;
+ unlimitedCache = new ConcurrentHashMap<String, Node>(1024);
+ }
+ }
+
+ private static final ConcurrentCache<String, Node> cache;
+ private static final ConcurrentHashMap<String, Node> unlimitedCache;
+
private FunctionMapper fnMapper;
private VariableMapper varMapper;
@@ -87,7 +118,7 @@
throw new ELException(MessageFactory.get("error.null"));
}
- Node n = (Node) cache.get(expr);
+ Node n = (cache != null) ? cache.get(expr) : unlimitedCache.get(expr);
if (n == null) {
try {
n = (new ELParser(new StringReader(expr)))
@@ -120,7 +151,11 @@
|| n instanceof AstDynamicExpression) {
n = n.jjtGetChild(0);
}
- cache.put(expr, n);
+ if (cache != null) {
+ cache.put(expr, n);
+ } else {
+ unlimitedCache.put(expr, n);
+ }
} catch (ParseException pe) {
throw new ELException("Error Parsing: " + expr, pe);
}
Modified: branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java
===================================================================
--- branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.el.util;
import java.util.Map;
@@ -6,34 +22,38 @@
public final class ConcurrentCache<K,V> {
- private final int size;
-
- private final Map<K,V> eden;
-
- private final Map<K,V> longterm;
-
- public ConcurrentCache(int size) {
- this.size = size;
- this.eden = new ConcurrentHashMap<K,V>(size);
- this.longterm = new WeakHashMap<K,V>(size);
- }
-
- public V get(K k) {
- V v = this.eden.get(k);
- if (v == null) {
- v = this.longterm.get(k);
- if (v != null) {
- this.eden.put(k, v);
- }
- }
- return v;
- }
-
- public void put(K k, V v) {
- if (this.eden.size() >= size) {
- this.longterm.putAll(this.eden);
- this.eden.clear();
- }
- this.eden.put(k, v);
- }
+ private final int size;
+
+ private final Map<K,V> eden;
+
+ private final Map<K,V> longterm;
+
+ public ConcurrentCache(int size) {
+ this.size = size;
+ this.eden = new ConcurrentHashMap<K,V>(size);
+ this.longterm = new WeakHashMap<K,V>(size);
+ }
+
+ public V get(K k) {
+ V v = this.eden.get(k);
+ if (v == null) {
+ synchronized (longterm) {
+ v = this.longterm.get(k);
+ }
+ if (v != null) {
+ this.eden.put(k, v);
+ }
+ }
+ return v;
+ }
+
+ public void put(K k, V v) {
+ if (this.eden.size() >= size) {
+ synchronized (longterm) {
+ this.longterm.putAll(this.eden);
+ }
+ this.eden.clear();
+ }
+ this.eden.put(k, v);
+ }
}
Modified: branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -139,9 +139,7 @@
pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty
.isTrimDirectiveWhitespaces()));
}
- if (jspProperty.getDefaultContentType() != null && pageInfo.getContentType() == null) {
- pageInfo.setContentType(jspProperty.getDefaultContentType());
- }
+ // Default ContentType processing is deferred until after the page has been parsed
if (jspProperty.getBuffer() != null && pageInfo.getBufferValue() == null) {
pageInfo.setBufferValue(jspProperty.getBuffer(), errDispatcher);
}
@@ -195,6 +193,10 @@
// Pass 2 - the whole translation unit
pageNodes = parserCtl.parse(ctxt.getJspFile());
+ if (jspProperty.getDefaultContentType() != null && pageInfo.getContentType() == null) {
+ pageInfo.setContentType(jspProperty.getDefaultContentType());
+ }
+
if (ctxt.isPrototypeMode()) {
// generate prototype .java file for the tag file
writer = setupContextWriter(javaFileName);
@@ -235,7 +237,7 @@
TextOptimizer.concatenate(this, pageNodes);
// Generate static function mapper codes.
- ELFunctionMapper.map(this, pageNodes);
+ ELFunctionMapper.map(pageNodes);
// generate servlet .java file
writer = setupContextWriter(javaFileName);
Modified: branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -17,13 +17,19 @@
package org.apache.jasper.compiler;
-import java.util.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import javax.servlet.jsp.tagext.FunctionInfo;
+
+import org.apache.jasper.Constants;
import org.apache.jasper.JasperException;
/**
* This class generates functions mappers for the EL expressions in the page.
- * Instead of a global mapper, a mapper is used for ecah call to EL
+ * Instead of a global mapper, a mapper is used for each call to EL
* evaluator, thus avoiding the prefix overlapping and redefinition
* issues.
*
@@ -38,25 +44,24 @@
/**
* Creates the functions mappers for all EL expressions in the JSP page.
*
- * @param compiler Current compiler, mainly for accessing error dispatcher.
* @param page The current compilation unit.
*/
- public static void map(Compiler compiler, Node.Nodes page)
- throws JasperException {
+ public static void map(Node.Nodes page)
+ throws JasperException {
- ELFunctionMapper map = new ELFunctionMapper();
- map.ds = new StringBuilder();
- map.ss = new StringBuilder();
+ ELFunctionMapper map = new ELFunctionMapper();
+ map.ds = new StringBuilder();
+ map.ss = new StringBuilder();
- page.visit(map.new ELFunctionVisitor());
+ page.visit(map.new ELFunctionVisitor());
- // Append the declarations to the root node
- String ds = map.ds.toString();
- if (ds.length() > 0) {
- Node root = page.getRoot();
- new Node.Declaration(map.ss.toString(), null, root);
- new Node.Declaration("static {\n" + ds + "}\n", null, root);
- }
+ // Append the declarations to the root node
+ String ds = map.ds.toString();
+ if (ds.length() > 0) {
+ Node root = page.getRoot();
+ new Node.Declaration(map.ss.toString(), null, root);
+ new Node.Declaration("static {\n" + ds + "}\n", null, root);
+ }
}
/**
@@ -64,182 +69,194 @@
* for functions, and if found functions mappers are created.
*/
class ELFunctionVisitor extends Node.Visitor {
-
- /**
- * Use a global name map to facilitate reuse of function maps.
- * The key used is prefix:function:uri.
- */
- private HashMap gMap = new HashMap();
+
+ /**
+ * Use a global name map to facilitate reuse of function maps.
+ * The key used is prefix:function:uri.
+ */
+ private HashMap<String, String> gMap = new HashMap<String, String>();
- public void visit(Node.ParamAction n) throws JasperException {
- doMap(n.getValue());
- visitBody(n);
- }
+ @Override
+ public void visit(Node.ParamAction n) throws JasperException {
+ doMap(n.getValue());
+ visitBody(n);
+ }
- public void visit(Node.IncludeAction n) throws JasperException {
- doMap(n.getPage());
- visitBody(n);
- }
+ @Override
+ public void visit(Node.IncludeAction n) throws JasperException {
+ doMap(n.getPage());
+ visitBody(n);
+ }
- public void visit(Node.ForwardAction n) throws JasperException {
- doMap(n.getPage());
- visitBody(n);
- }
+ @Override
+ public void visit(Node.ForwardAction n) throws JasperException {
+ doMap(n.getPage());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.SetProperty n) throws JasperException {
- doMap(n.getValue());
- visitBody(n);
- }
+ doMap(n.getValue());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.UseBean n) throws JasperException {
- doMap(n.getBeanName());
- visitBody(n);
- }
+ doMap(n.getBeanName());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.PlugIn n) throws JasperException {
- doMap(n.getHeight());
- doMap(n.getWidth());
- visitBody(n);
- }
+ doMap(n.getHeight());
+ doMap(n.getWidth());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.JspElement n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- doMap(n.getNameAttribute());
- visitBody(n);
- }
+ Node.JspAttribute[] attrs = n.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ doMap(attrs[i]);
+ }
+ doMap(n.getNameAttribute());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.UninterpretedTag n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- visitBody(n);
- }
+ Node.JspAttribute[] attrs = n.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ doMap(attrs[i]);
+ }
+ visitBody(n);
+ }
+ @Override
public void visit(Node.CustomTag n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- visitBody(n);
- }
+ Node.JspAttribute[] attrs = n.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ doMap(attrs[i]);
+ }
+ visitBody(n);
+ }
+ @Override
public void visit(Node.ELExpression n) throws JasperException {
- doMap(n.getEL());
- }
+ doMap(n.getEL());
+ }
- private void doMap(Node.JspAttribute attr)
- throws JasperException {
- if (attr != null) {
- doMap(attr.getEL());
- }
- }
+ private void doMap(Node.JspAttribute attr)
+ throws JasperException {
+ if (attr != null) {
+ doMap(attr.getEL());
+ }
+ }
/**
* Creates function mappers, if needed, from ELNodes
*/
- private void doMap(ELNode.Nodes el)
- throws JasperException {
+ private void doMap(ELNode.Nodes el)
+ throws JasperException {
// Only care about functions in ELNode's
- class Fvisitor extends ELNode.Visitor {
- ArrayList funcs = new ArrayList();
- HashMap keyMap = new HashMap();
- public void visit(ELNode.Function n) throws JasperException {
- String key = n.getPrefix() + ":" + n.getName();
- if (! keyMap.containsKey(key)) {
- keyMap.put(key,"");
- funcs.add(n);
- }
- }
- }
+ class Fvisitor extends ELNode.Visitor {
+ ArrayList<ELNode.Function> funcs =
+ new ArrayList<ELNode.Function>();
+ HashMap<String, String> keyMap = new HashMap<String, String>();
+ @Override
+ public void visit(ELNode.Function n) throws JasperException {
+ String key = n.getPrefix() + ":" + n.getName();
+ if (! keyMap.containsKey(key)) {
+ keyMap.put(key,"");
+ funcs.add(n);
+ }
+ }
+ }
- if (el == null) {
- return;
- }
+ if (el == null) {
+ return;
+ }
- // First locate all unique functions in this EL
- Fvisitor fv = new Fvisitor();
- el.visit(fv);
- ArrayList functions = fv.funcs;
+ // First locate all unique functions in this EL
+ Fvisitor fv = new Fvisitor();
+ el.visit(fv);
+ ArrayList<ELNode.Function> functions = fv.funcs;
- if (functions.size() == 0) {
- return;
- }
+ if (functions.size() == 0) {
+ return;
+ }
- // Reuse a previous map if possible
- String decName = matchMap(functions);
- if (decName != null) {
- el.setMapName(decName);
- return;
- }
-
- // Generate declaration for the map statically
- decName = getMapName();
- ss.append("static private org.apache.jasper.runtime.ProtectedFunctionMapper " + decName + ";\n");
+ // Reuse a previous map if possible
+ String decName = matchMap(functions);
+ if (decName != null) {
+ el.setMapName(decName);
+ return;
+ }
+
+ // Generate declaration for the map statically
+ decName = getMapName();
+ ss.append("static private org.apache.jasper.runtime.ProtectedFunctionMapper " + decName + ";\n");
- ds.append(" " + decName + "= ");
- ds.append("org.apache.jasper.runtime.ProtectedFunctionMapper");
+ ds.append(" " + decName + "= ");
+ ds.append("org.apache.jasper.runtime.ProtectedFunctionMapper");
- // Special case if there is only one function in the map
- String funcMethod = null;
- if (functions.size() == 1) {
- funcMethod = ".getMapForFunction";
- } else {
- ds.append(".getInstance();\n");
- funcMethod = " " + decName + ".mapFunction";
- }
+ // Special case if there is only one function in the map
+ String funcMethod = null;
+ if (functions.size() == 1) {
+ funcMethod = ".getMapForFunction";
+ } else {
+ ds.append(".getInstance();\n");
+ funcMethod = " " + decName + ".mapFunction";
+ }
// Setup arguments for either getMapForFunction or mapFunction
- for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
- FunctionInfo funcInfo = f.getFunctionInfo();
- String key = f.getPrefix()+ ":" + f.getName();
- ds.append(funcMethod + "(\"" + key + "\", " +
- funcInfo.getFunctionClass() + ".class, " +
- '\"' + f.getMethodName() + "\", " +
- "new Class[] {");
- String params[] = f.getParameters();
- for (int k = 0; k < params.length; k++) {
- if (k != 0) {
- ds.append(", ");
- }
- int iArray = params[k].indexOf('[');
- if (iArray < 0) {
- ds.append(params[k] + ".class");
- }
- else {
- String baseType = params[k].substring(0, iArray);
- ds.append("java.lang.reflect.Array.newInstance(");
- ds.append(baseType);
- ds.append(".class,");
+ for (int i = 0; i < functions.size(); i++) {
+ ELNode.Function f = functions.get(i);
+ FunctionInfo funcInfo = f.getFunctionInfo();
+ String key = f.getPrefix()+ ":" + f.getName();
+ ds.append(funcMethod + "(\"" + key + "\", " +
+ getCanonicalName(funcInfo.getFunctionClass()) +
+ ".class, " + '\"' + f.getMethodName() + "\", " +
+ "new Class[] {");
+ String params[] = f.getParameters();
+ for (int k = 0; k < params.length; k++) {
+ if (k != 0) {
+ ds.append(", ");
+ }
+ int iArray = params[k].indexOf('[');
+ if (iArray < 0) {
+ ds.append(params[k] + ".class");
+ }
+ else {
+ String baseType = params[k].substring(0, iArray);
+ ds.append("java.lang.reflect.Array.newInstance(");
+ ds.append(baseType);
+ ds.append(".class,");
- // Count the number of array dimension
- int aCount = 0;
- for (int jj = iArray; jj < params[k].length(); jj++ ) {
- if (params[k].charAt(jj) == '[') {
- aCount++;
- }
- }
- if (aCount == 1) {
- ds.append("0).getClass()");
- } else {
- ds.append("new int[" + aCount + "]).getClass()");
- }
- }
- }
- ds.append("});\n");
- // Put the current name in the global function map
- gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(),
- decName);
- }
- el.setMapName(decName);
- }
+ // Count the number of array dimension
+ int aCount = 0;
+ for (int jj = iArray; jj < params[k].length(); jj++ ) {
+ if (params[k].charAt(jj) == '[') {
+ aCount++;
+ }
+ }
+ if (aCount == 1) {
+ ds.append("0).getClass()");
+ } else {
+ ds.append("new int[" + aCount + "]).getClass()");
+ }
+ }
+ }
+ ds.append("});\n");
+ // Put the current name in the global function map
+ gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(),
+ decName);
+ }
+ el.setMapName(decName);
+ }
/**
* Find the name of the function mapper for an EL. Reuse a
@@ -249,32 +266,66 @@
* @return A previous generated function mapper name that can be used
* by this EL; null if none found.
*/
- private String matchMap(ArrayList functions) {
+ private String matchMap(ArrayList<ELNode.Function> functions) {
- String mapName = null;
- for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
- String temName = (String) gMap.get(f.getPrefix() + ':' +
- f.getName() + ':' + f.getUri());
- if (temName == null) {
- return null;
- }
- if (mapName == null) {
- mapName = temName;
- } else if (!temName.equals(mapName)) {
- // If not all in the previous match, then no match.
- return null;
- }
- }
- return mapName;
- }
+ String mapName = null;
+ for (int i = 0; i < functions.size(); i++) {
+ ELNode.Function f = functions.get(i);
+ String temName = gMap.get(f.getPrefix() + ':' + f.getName() +
+ ':' + f.getUri());
+ if (temName == null) {
+ return null;
+ }
+ if (mapName == null) {
+ mapName = temName;
+ } else if (!temName.equals(mapName)) {
+ // If not all in the previous match, then no match.
+ return null;
+ }
+ }
+ return mapName;
+ }
/*
* @return An unique name for a function mapper.
*/
- private String getMapName() {
- return "_jspx_fnmap_" + currFunc++;
- }
+ private String getMapName() {
+ return "_jspx_fnmap_" + currFunc++;
+ }
+
+ /**
+ * Convert a binary class name into a canonical one that can be used
+ * when generating Java source code.
+ *
+ * @param className Binary class name
+ * @return Canonical equivalent
+ */
+ private String getCanonicalName(String className) throws JasperException {
+ Class<?> clazz;
+
+ ClassLoader tccl;
+ if (Constants.IS_SECURITY_ENABLED) {
+ PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
+ tccl = AccessController.doPrivileged(pa);
+ } else {
+ tccl = Thread.currentThread().getContextClassLoader();
+ }
+
+ try {
+ clazz = Class.forName(className, true, tccl);
+ } catch (ClassNotFoundException e) {
+ throw new JasperException(e);
+ }
+ return clazz.getCanonicalName();
+ }
}
+
+ private static class PrivilegedGetTccl
+ implements PrivilegedAction<ClassLoader> {
+
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ }
}
Modified: branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -100,10 +100,10 @@
public char[] getContents() {
char[] result = null;
FileInputStream is = null;
+ Reader reader = null;
try {
is = new FileInputStream(sourceFile);
- Reader reader =
- new BufferedReader(new InputStreamReader(is, ctxt.getOptions().getJavaEncoding()));
+ reader = new BufferedReader(new InputStreamReader(is, ctxt.getOptions().getJavaEncoding()));
if (reader != null) {
char[] chars = new char[8192];
StringBuilder buf = new StringBuilder();
@@ -118,6 +118,13 @@
} catch (IOException e) {
log.error("Compilation error", e);
} finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException exc) {
+ // Ignore
+ }
+ }
if (is != null) {
try {
is.close();
Modified: branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -60,11 +60,6 @@
"http://xml.org/sax/properties/lexical-handler";
private static final String JSP_URI = "http://java.sun.com/JSP/Page";
- private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION =
- new EnableDTDValidationException(
- "jsp.error.enable_dtd_validation",
- null);
-
private ParserController parserController;
private JspCompilationContext ctxt;
private PageInfo pageInfo;
@@ -751,7 +746,7 @@
public void startDTD(String name, String publicId, String systemId)
throws SAXException {
if (!isValidating) {
- fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
+ fatalError(new EnableDTDValidationException("jsp.error.enable_dtd_validation", null));
}
inDTD = true;
@@ -793,7 +788,7 @@
taglibInfo = getTaglibInfo(prefix, uri);
} catch (JasperException je) {
throw new SAXParseException(
- Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
+ Localizer.getMessage("jsp.error.could.not.add.taglibraries", je.getMessage()),
locator,
je);
}
@@ -1450,6 +1445,11 @@
EnableDTDValidationException(String message, Locator loc) {
super(message, loc);
}
+
+ public synchronized Throwable fillInStackTrace() {
+ // No stack trace
+ return this;
+ }
}
private static String getBodyType(Node.CustomTag custom) {
Modified: branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -612,10 +612,12 @@
&& Character.isWhitespace(root.charAt(index))) {
index++;
}
- if (index < root.length() && root.charAt(index++) == '"'
- && root.regionMatches(index, JSP_URI, 0,
- JSP_URI.length())) {
- return true;
+ if (index < root.length()
+ && (root.charAt(index) == '"' || root.charAt(index) == '\'')) {
+ index++;
+ if (root.regionMatches(index, JSP_URI, 0, JSP_URI.length())) {
+ return true;
+ }
}
}
Modified: branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -596,8 +595,7 @@
rctxt.addWrapper(tagFileJarPath + tagFilePath, wrapper);
// Use same classloader and classpath for compiling tag files
- wrapper.getJspEngineContext().setClassLoader(
- (URLClassLoader) ctxt.getClassLoader());
+ wrapper.getJspEngineContext().setClassLoader(ctxt.getClassLoader());
wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
} else {
// Make sure that JspCompilationContext gets the latest TagInfo
@@ -620,6 +618,9 @@
.getServletContext(), ctxt.getOptions(),
tagFilePath, tagInfo, ctxt.getRuntimeContext(),
ctxt.getTagFileJarUrl(tagFilePath));
+ // Use same classloader and classpath for compiling tag files
+ tempWrapper.getJspEngineContext().setClassLoader(ctxt.getClassLoader());
+ tempWrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
tagClazz = tempWrapper.loadTagFilePrototype();
tempVector.add(tempWrapper.getJspEngineContext()
.getCompiler());
Modified: branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -301,8 +301,13 @@
e);
}
}
-
- return new TagInfo(tagInfo.getTagName(), tagInfo.getTagClassName(), tagInfo.getBodyContent(),
+
+ String tagBodyContent = tagInfo.getBodyContent();
+ if (tagBodyContent == null) {
+ tagBodyContent = TagInfo.BODY_CONTENT_JSP;
+ }
+
+ return new TagInfo(tagInfo.getTagName(), tagInfo.getTagClassName(), tagBodyContent,
tagInfo.getInfoString(), this, tei, attributeInfos.toArray(new TagAttributeInfo[0]),
tagInfo.getDisplayName(), tagInfo.getSmallIcon(), tagInfo.getLargeIcon(),
variableInfos.toArray(new TagVariableInfo[0]), dynamicAttributes);
Modified: branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -69,7 +69,7 @@
public ELContextImpl() {
this(ELResolverImpl.getDefaultResolver());
- if (Constants.IS_SECURITY_ENABLED) {
+ if (ELResolverImpl.NEW_RESOLVER_INSTANCE && Constants.IS_SECURITY_ENABLED) {
functionMapper = new FunctionMapper() {
public Method resolveFunction(String prefix, String localName) {
return null;
Modified: branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java 2011-01-04 09:04:39 UTC (rev 1630)
@@ -36,9 +36,12 @@
public final class ELResolverImpl extends ELResolver {
- /** @deprecated - Use getDefaultResolver(). Needs to be made private */
- public final static ELResolver DefaultResolver = new CompositeELResolver();
+ public static final boolean NEW_RESOLVER_INSTANCE =
+ Boolean.valueOf(System.getProperty("org.apache.jasper.el.ELResolverImpl.NEW_RESOLVER_INSTANCE", "false")).booleanValue();
+
+ private final static ELResolver DefaultResolver = new CompositeELResolver();
+
static {
((CompositeELResolver) DefaultResolver).add(new MapELResolver());
((CompositeELResolver) DefaultResolver).add(new ResourceBundleELResolver());
@@ -147,7 +150,7 @@
}
public static ELResolver getDefaultResolver() {
- if (Constants.IS_SECURITY_ENABLED) {
+ if (NEW_RESOLVER_INSTANCE && Constants.IS_SECURITY_ENABLED) {
CompositeELResolver defaultResolver = new CompositeELResolver();
defaultResolver.add(new MapELResolver());
defaultResolver.add(new ResourceBundleELResolver());
Modified: branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties
===================================================================
--- branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties 2011-01-04 09:04:39 UTC (rev 1630)
@@ -344,7 +344,7 @@
jsp.error.coerce_to_type=Cannot coerce value ({2}) to type ({1}) for attribute {0}.
jsp.error.jspelement.missing.name=Mandatory XML-style \'name\' attribute missing
jsp.error.xmlns.redefinition.notimplemented=Internal error: Attempt to redefine xmlns:{0}. Redefinition of namespaces is not implemented.
-jsp.error.could.not.add.taglibraries=Could not add one or more tag libraries.
+jsp.error.could.not.add.taglibraries=Could not add one or more tag libraries: {0}
jsp.error.duplicate.name.jspattribute=The attribute {0} specified in the standard or custom action also appears as the value of the name attribute in the enclosed jsp:attribute
jsp.error.not.in.template={0} not allowed in a template text body.
jsp.error.badStandardAction=Invalid standard action
Modified: branches/3.0.x/webapps/docs/changelog.xml
===================================================================
--- branches/3.0.x/webapps/docs/changelog.xml 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/webapps/docs/changelog.xml 2011-01-04 09:04:39 UTC (rev 1630)
@@ -16,6 +16,45 @@
<body>
+<section name="JBoss Web 3.0.0.CR2 (remm)">
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <jboss-jira>JBAS-8579</jboss-jira>: Fix default for tag body content. (remm)
+ </fix>
+ <fix>
+ <jira>185</jira>: Fix cache thread safety issue for EL expression builder.
+ Patch submitted by Takayoshi Kimura. (remm)
+ </fix>
+ <fix>
+ <bug>50192</bug>: Fix regression getting the EL resolver. Tighter security can
+ be enabled back. (remm)
+ </fix>
+ <fix>
+ <bug>49555</bug>: Fix use of static inner classes in taglibs. (markt)
+ </fix>
+ <fix>
+ <bug>49726</bug>: Specifying a default content type via a JSP property group
+ should not prevent a page from setting some other content type. (markt)
+ </fix>
+ <fix>
+ <bug>49998</bug>: Handle single quoted attributes in detection of jsp:root
+ element in XML syntax JSP files. (markt)
+ </fix>
+ <fix>
+ <bug>50066</bug>: Fix building of recursive tag files when the file depends on a JAR file.
+ Patch provided by Sylvain Laurent. (markt)
+ </fix>
+ <fix>
+ <bug>50105</bug>: Use Enum.name() rather than Enum.toString() in composite expressions. (markt)
+ </fix>
+ <fix>
+ Close reader in JDT compiler. (markt)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 3.0.0.CR1 (remm)">
<subsection name="Catalina">
<changelog>
13 years, 11 months