JBossWeb SVN: r594 - branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746/src/share/classes/org/apache/tomcat/util/http.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-04-28 06:34:15 -0400 (Mon, 28 Apr 2008)
New Revision: 594
Modified:
branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746/src/share/classes/org/apache/tomcat/util/http/Parameters.java
Log:
JBAPP729: r568. Encoding problems with login (form based) pages.
Modified: branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746/src/share/classes/org/apache/tomcat/util/http/Parameters.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746/src/share/classes/org/apache/tomcat/util/http/Parameters.java 2008-04-28 10:29:09 UTC (rev 593)
+++ branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746/src/share/classes/org/apache/tomcat/util/http/Parameters.java 2008-04-28 10:34:15 UTC (rev 594)
@@ -503,17 +503,12 @@
public void processParameters( MessageBytes data, String encoding ) {
if( data==null || data.isNull() || data.getLength() <= 0 ) return;
- if( data.getType() == MessageBytes.T_BYTES ) {
- ByteChunk bc=data.getByteChunk();
- processParameters( bc.getBytes(), bc.getOffset(),
- bc.getLength(), encoding);
- } else {
- if (data.getType()!= MessageBytes.T_CHARS )
- data.toChars();
- CharChunk cc=data.getCharChunk();
- processParameters( cc.getChars(), cc.getOffset(),
- cc.getLength());
+ if (data.getType() != MessageBytes.T_BYTES) {
+ data.toBytes();
}
+ ByteChunk bc=data.getByteChunk();
+ processParameters( bc.getBytes(), bc.getOffset(),
+ bc.getLength(), encoding);
}
/** Debug purpose
16 years, 8 months
JBossWeb SVN: r593 - branches.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-04-28 06:29:09 -0400 (Mon, 28 Apr 2008)
New Revision: 593
Added:
branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746/
Log:
Branche to fix:
JBAPP-724: For 168408 and 175434 (r568)
JBAPP-746: For 171944 and 174850 (r578)
Copied: branches/JBOSSWEB_2_0_0_GA_CP05_JBAPP729_JBAPP746 (from rev 592, tags/JBOSSWEB_2_0_0_GA_CP05)
16 years, 8 months
JBossWeb SVN: r592 - trunk/java/org/apache/tomcat/util/net.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-04-24 10:50:38 -0400 (Thu, 24 Apr 2008)
New Revision: 592
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
Log:
Try to use a range of port and always try on port on which we have made less connections.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-04-22 19:37:24 UTC (rev 591)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-04-24 14:50:38 UTC (rev 592)
@@ -371,6 +371,14 @@
protected boolean reverseConnection = false;
public boolean isReverseConnection() { return reverseConnection; }
public void setReverseConnection(boolean reverseConnection) { this.reverseConnection = reverseConnection; }
+ /**
+ * List of socket counters.
+ */
+ class ListSock {
+ int count;
+ int port;
+ }
+ protected ListSock[] listsock = null;
/**
@@ -617,6 +625,13 @@
deferAccept = false;
}
} else {
+ /* Initialize the SockList */
+ listsock = new ListSock[10];
+ for (int i=0; i<listsock.length; i++) {
+ listsock[i] = new ListSock();
+ listsock[i].port = port + i;
+ listsock[i].count = 0;
+ }
serverAddress = inetAddress;
serverAddressFamily = family;
deferAccept = false;
@@ -1053,16 +1068,42 @@
if (reverseConnection) {
if (poller.getConnectionCount() < (maxThreads / 5)) {
+ /* Sort the ListSock (by count) */
+ boolean go = true;
+ while (go) {
+ go = false;
+ for (int i=0; i<listsock.length -1; i++) {
+ ListSock current;
+ if (listsock[i+1].count<listsock[i].count) {
+ go = false;
+ current = listsock[i+1];
+ listsock[i+1] = listsock[i];
+ listsock[i] = current;
+ }
+ }
+ }
+
// Create maxThreads / 5 sockets
- try {
- for (int i = 0; i < (maxThreads / 5); i++) {
+ int nsock = maxThreads / 5;
+ if (nsock>listsock.length)
+ nsock = listsock.length;
+ String addressStr = address.getHostAddress();
+ for (int i=0; i < nsock; i++) {
+ try {
long socket = Socket.create(serverAddressFamily, Socket.SOCK_STREAM,
Socket.APR_PROTO_TCP, rootPool);
- Socket.connect(socket, serverAddress);
+ long inetAddress = Address.info(addressStr, serverAddressFamily,
+ listsock[i].port, 0, rootPool);
+ if (Socket.connect(socket, inetAddress) != 0) {
+ Socket.destroy(socket);
+ continue; // try next one.
+ }
// Hand this socket off to an appropriate processor
if (!processSocketWithOptions(socket)) {
// Close socket and pool right away
Socket.destroy(socket);
+ } else {
+ listsock[i].count++;
}
// Don't immediately create another socket
try {
@@ -1070,9 +1111,9 @@
} catch (InterruptedException e) {
// Ignore
}
+ } catch (Throwable t) {
+ log.error(sm.getString("endpoint.accept.fail"), t);
}
- } catch (Throwable t) {
- log.error(sm.getString("endpoint.accept.fail"), t);
}
}
try {
16 years, 8 months
JBossWeb SVN: r590 - in trunk: java/org/apache/catalina/core and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-22 12:06:47 -0400 (Tue, 22 Apr 2008)
New Revision: 590
Modified:
trunk/java/org/apache/catalina/Container.java
trunk/java/org/apache/catalina/core/ContainerBase.java
trunk/java/org/apache/catalina/core/StandardContextValve.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/el/lang/ELSupport.java
trunk/java/org/apache/jasper/compiler/AntCompiler.java
trunk/webapps/docs/changelog.xml
Log:
- Port a bunch of Tomcat patches.
- Add (for now) isStarted to Container.
- Need to review JBossContextConfig.
Modified: trunk/java/org/apache/catalina/Container.java
===================================================================
--- trunk/java/org/apache/catalina/Container.java 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/java/org/apache/catalina/Container.java 2008-04-22 16:06:47 UTC (rev 590)
@@ -133,6 +133,13 @@
/**
+ * Return if the container is started. This sort of conflicts with lifecycle
+ * but the purpose should be evident enough.
+ */
+ public boolean isStarted();
+
+
+ /**
* Return descriptive information about this Container implementation and
* the corresponding version number, in the format
* <code><description>/<version></code>.
Modified: trunk/java/org/apache/catalina/core/ContainerBase.java
===================================================================
--- trunk/java/org/apache/catalina/core/ContainerBase.java 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/java/org/apache/catalina/core/ContainerBase.java 2008-04-22 16:06:47 UTC (rev 590)
@@ -283,6 +283,15 @@
/**
+ * Return if the container is started. This sort of conflicts with lifecycle
+ * but the purpose should be evident enough.
+ */
+ public boolean isStarted() {
+ return started;
+ }
+
+
+ /**
* Get the delay between the invocation of the backgroundProcess method on
* this container and its children. Child containers will not be invoked
* if their delay value is not negative (which would mean they are using
Modified: trunk/java/org/apache/catalina/core/StandardContextValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContextValve.java 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/java/org/apache/catalina/core/StandardContextValve.java 2008-04-22 16:06:47 UTC (rev 590)
@@ -140,6 +140,14 @@
String requestURI = request.getDecodedRequestURI();
notFound(requestURI, response);
return;
+ } else if (!wrapper.isStarted()) {
+ // May be as a result of a reload, try and find the new wrapper
+ wrapper = (Wrapper) container.findChild(wrapper.getName());
+ if (wrapper == null) {
+ String requestURI = request.getDecodedRequestURI();
+ notFound(requestURI, response);
+ return;
+ }
}
// Normal request processing
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2008-04-22 16:06:47 UTC (rev 590)
@@ -339,10 +339,6 @@
long t1=System.currentTimeMillis();
- if (webDigester == null){
- webDigester = createWebDigester();
- }
-
URL url=null;
// Process the application web.xml file
synchronized (webDigester) {
@@ -624,10 +620,6 @@
+ " " + defaultWebXml + " " + file , e);
}
- if (webDigester == null){
- webDigester = createWebDigester();
- }
-
if (stream != null) {
processDefaultWebConfig(webDigester, stream, source);
webRuleSet.recycle();
@@ -786,9 +778,6 @@
if (source == null)
return;
- if (contextDigester == null){
- contextDigester = createContextDigester();
- }
synchronized (contextDigester) {
try {
source.setByteStream(stream);
@@ -997,6 +986,16 @@
protected void init() {
// Called from StandardContext.init()
+ if (webDigester == null){
+ webDigester = createWebDigester();
+ webDigester.getParser();
+ }
+
+ if (contextDigester == null){
+ contextDigester = createContextDigester();
+ contextDigester.getParser();
+ }
+
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.init"));
context.setConfigured(false);
Modified: trunk/java/org/apache/el/lang/ELSupport.java
===================================================================
--- trunk/java/org/apache/el/lang/ELSupport.java 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/java/org/apache/el/lang/ELSupport.java 2008-04-22 16:06:47 UTC (rev 590)
@@ -225,9 +225,15 @@
if (number instanceof BigDecimal) {
return ((BigDecimal) number).toBigInteger();
}
+ if (number instanceof BigInteger) {
+ return new BigInteger(number.toString());
+ }
return BigInteger.valueOf(number.longValue());
}
if (BigDecimal.class.equals(type)) {
+ if (number instanceof BigDecimal) {
+ return new BigDecimal(number.toString());
+ }
if (number instanceof BigInteger) {
return new BigDecimal((BigInteger) number);
}
@@ -336,7 +342,8 @@
public final static Object coerceToType(final Object obj, final Class type)
throws IllegalArgumentException {
- if (type == null || Object.class.equals(type)) {
+ if (type == null || Object.class.equals(type) ||
+ type.equals(obj.getClass())) {
return obj;
}
if (String.class.equals(type)) {
Modified: trunk/java/org/apache/jasper/compiler/AntCompiler.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/AntCompiler.java 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/java/org/apache/jasper/compiler/AntCompiler.java 2008-04-22 16:06:47 UTC (rev 590)
@@ -175,8 +175,8 @@
if(endorsed != null) {
Javac.ImplementationSpecificArgument endorsedArg =
javac.createCompilerArg();
- endorsedArg.setLine("-J-Djava.endorsed.dirs="+endorsed);
- info.append(" endorsed dir=" + endorsed + "\n");
+ endorsedArg.setLine("-J-Djava.endorsed.dirs=" + quotePathList(endorsed));
+ info.append(" endorsed dir=" + quotePathList(endorsed) + "\n");
} else {
info.append(" no endorsed dirs specified\n");
}
@@ -276,6 +276,26 @@
}
+ private String quotePathList(String list) {
+ StringBuffer result = new StringBuffer(list.length() + 10);
+ StringTokenizer st = new StringTokenizer(list, File.pathSeparator);
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if (token.indexOf(' ') == -1) {
+ result.append(token);
+ } else {
+ result.append('\"');
+ result.append(token);
+ result.append('\"');
+ }
+ if (st.hasMoreTokens()) {
+ result.append(File.pathSeparatorChar);
+ }
+ }
+ return result.toString();
+ }
+
+
protected static class SystemLogHandler extends PrintStream {
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-04-21 16:09:30 UTC (rev 589)
+++ trunk/webapps/docs/changelog.xml 2008-04-22 16:06:47 UTC (rev 590)
@@ -71,6 +71,13 @@
Add system properties for JBoss default allowing not starting the context in init, and set
the configClass field. (remm)
</fix>
+ <fix>
+ <bug>43683</bug>: Need to identify new wrapper for queued request after reload. (remm)
+ </fix>
+ <fix>
+ <bug>29936</bug>: In some circumstances, Tomcat would use the parser from a webapp
+ to parse web.xml and possibly context.xml files. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
@@ -129,6 +136,13 @@
<fix>
Make number types handling more flexible in EL. (markt)
</fix>
+ <fix>
+ <bug>43656</bug>: coerceToType() modified some values, and additional numeric type fixes.
+ Patch provided by Nils Eckert. (markt)
+ </fix>
+ <fix>
+ <bug>31257</bug>: Quote endorsed dirs if they contain a space. (markt)
+ </fix>
</changelog>
</subsection>
</section>
16 years, 8 months
JBossWeb SVN: r589 - in trunk: java/org/apache/coyote/http11 and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-21 12:09:30 -0400 (Mon, 21 Apr 2008)
New Revision: 589
Modified:
trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
trunk/webapps/docs/changelog.xml
Log:
- Add (untested) reverse connection logic, as requested by sales. Not very hard to do on the Java side.
The connection logic is pretty simple and could use improvements.
Modified: trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
===================================================================
--- trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java 2008-04-21 13:06:14 UTC (rev 588)
+++ trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java 2008-04-21 16:09:30 UTC (rev 589)
@@ -290,6 +290,9 @@
public int getSoTimeout() { return endpoint.getSoTimeout(); }
public void setSoTimeout(int soTimeout) { endpoint.setSoTimeout(soTimeout); }
+ public boolean getReverseConnection() { return endpoint.isReverseConnection(); }
+ public void setReverseConnection(boolean reverseConnection) { endpoint.setReverseConnection(reverseConnection); }
+
/**
* Should authentication be done in the native webserver layer,
* or in the Servlet container ?
Modified: trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 2008-04-21 13:06:14 UTC (rev 588)
+++ trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 2008-04-21 16:09:30 UTC (rev 589)
@@ -244,6 +244,9 @@
public int getSoTimeout() { return endpoint.getSoTimeout(); }
public void setSoTimeout(int soTimeout) { endpoint.setSoTimeout(soTimeout); }
+ public boolean getReverseConnection() { return endpoint.isReverseConnection(); }
+ public void setReverseConnection(boolean reverseConnection) { endpoint.setReverseConnection(reverseConnection); }
+
/**
* The number of seconds Tomcat will wait for a subsequent request
* before closing the connection.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-04-21 13:06:14 UTC (rev 588)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-04-21 16:09:30 UTC (rev 589)
@@ -353,6 +353,27 @@
/**
+ * The server address.
+ */
+ protected long serverAddress = 0;
+
+
+ /**
+ * The server address family.
+ */
+ protected int serverAddressFamily = 0;
+
+
+ /**
+ * Reverse connection. In this proxied mode, the endpoint will not use a server
+ * socket, but will connect itself to the front end server.
+ */
+ protected boolean reverseConnection = false;
+ public boolean isReverseConnection() { return reverseConnection; }
+ public void setReverseConnection(boolean reverseConnection) { this.reverseConnection = reverseConnection; }
+
+
+ /**
* SSL engine.
*/
protected boolean SSLEnabled = false;
@@ -557,46 +578,53 @@
}
}
- long inetAddress = Address.info(addressStr, family,
- port, 0, rootPool);
- // Create the APR server socket
- serverSock = Socket.create(family, Socket.SOCK_STREAM,
- Socket.APR_PROTO_TCP, rootPool);
- if (OS.IS_UNIX) {
- Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
- }
- // Deal with the firewalls that tend to drop the inactive sockets
- Socket.optSet(serverSock, Socket.APR_SO_KEEPALIVE, 1);
- // Bind the server socket
- int ret = Socket.bind(serverSock, inetAddress);
- if (ret != 0) {
- throw new Exception(sm.getString("endpoint.init.bind", "" + ret, Error.strerror(ret)));
- }
- // Start listening on the server socket
- ret = Socket.listen(serverSock, backlog);
- if (ret != 0) {
- throw new Exception(sm.getString("endpoint.init.listen", "" + ret, Error.strerror(ret)));
- }
- if (OS.IS_WIN32 || OS.IS_WIN64) {
- // On Windows set the reuseaddr flag after the bind/listen
- Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
- }
-
// Sendfile usage on systems which don't support it cause major problems
if (useSendfile && !Library.APR_HAS_SENDFILE) {
useSendfile = false;
}
- // Delay accepting of new connections until data is available
- // Only Linux kernels 2.4 + have that implemented
- // on other platforms this call is noop and will return APR_ENOTIMPL.
- if (Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1) == Status.APR_ENOTIMPL) {
+ long inetAddress = Address.info(addressStr, family,
+ port, 0, rootPool);
+
+ if (!reverseConnection) {
+ // Create the APR server socket
+ serverSock = Socket.create(family, Socket.SOCK_STREAM,
+ Socket.APR_PROTO_TCP, rootPool);
+ if (OS.IS_UNIX) {
+ Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
+ }
+ // Deal with the firewalls that tend to drop the inactive sockets
+ Socket.optSet(serverSock, Socket.APR_SO_KEEPALIVE, 1);
+ // Bind the server socket
+ int ret = Socket.bind(serverSock, inetAddress);
+ if (ret != 0) {
+ throw new Exception(sm.getString("endpoint.init.bind", "" + ret, Error.strerror(ret)));
+ }
+ // Start listening on the server socket
+ ret = Socket.listen(serverSock, backlog);
+ if (ret != 0) {
+ throw new Exception(sm.getString("endpoint.init.listen", "" + ret, Error.strerror(ret)));
+ }
+ if (OS.IS_WIN32 || OS.IS_WIN64) {
+ // On Windows set the reuseaddr flag after the bind/listen
+ Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
+ }
+
+ // Delay accepting of new connections until data is available
+ // Only Linux kernels 2.4 + have that implemented
+ // on other platforms this call is noop and will return APR_ENOTIMPL.
+ if (Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1) == Status.APR_ENOTIMPL) {
+ deferAccept = false;
+ }
+ } else {
+ serverAddress = inetAddress;
+ serverAddressFamily = family;
deferAccept = false;
}
// Initialize SSL if needed
if (SSLEnabled) {
-
+
// SSL protocol
int value = SSL.SSL_PROTOCOL_ALL;
if ("SSLv2".equalsIgnoreCase(SSLProtocol)) {
@@ -609,7 +637,7 @@
value = SSL.SSL_PROTOCOL_SSLV2 | SSL.SSL_PROTOCOL_SSLV3;
}
// Create SSL Context
- sslContext = SSLContext.make(rootPool, value, SSL.SSL_MODE_SERVER);
+ sslContext = SSLContext.make(rootPool, value, (reverseConnection) ? SSL.SSL_MODE_CLIENT : SSL.SSL_MODE_SERVER);
// List the ciphers that the client is permitted to negotiate
SSLContext.setCipherSuite(sslContext, SSLCipherSuite);
// Load Server key and certificate
@@ -632,8 +660,9 @@
SSLContext.setVerify(sslContext, value, SSLVerifyDepth);
// For now, sendfile is not supported with SSL
useSendfile = false;
+
}
-
+
initialized = true;
}
@@ -1022,16 +1051,49 @@
}
}
- try {
- // Accept the next incoming connection from the server socket
- long socket = Socket.accept(serverSock);
- // Hand this socket off to an appropriate processor
- if (!processSocketWithOptions(socket)) {
- // Close socket and pool right away
- Socket.destroy(socket);
+ if (reverseConnection) {
+ if (poller.getConnectionCount() < (maxThreads / 5)) {
+ // Create maxThreads / 5 sockets
+ try {
+ for (int i = 0; i < (maxThreads / 5); i++) {
+ long socket = Socket.create(serverAddressFamily, Socket.SOCK_STREAM,
+ Socket.APR_PROTO_TCP, rootPool);
+ Socket.connect(socket, serverAddress);
+ // Hand this socket off to an appropriate processor
+ if (!processSocketWithOptions(socket)) {
+ // Close socket and pool right away
+ Socket.destroy(socket);
+ }
+ // Don't immediately create another socket
+ try {
+ Thread.sleep(1);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+ } catch (Throwable t) {
+ log.error(sm.getString("endpoint.accept.fail"), t);
+ }
}
- } catch (Throwable t) {
- log.error(sm.getString("endpoint.accept.fail"), t);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ } else {
+
+ try {
+ // Accept the next incoming connection from the server socket
+ long socket = Socket.accept(serverSock);
+ // Hand this socket off to an appropriate processor
+ if (!processSocketWithOptions(socket)) {
+ // Close socket and pool right away
+ Socket.destroy(socket);
+ }
+ } catch (Throwable t) {
+ log.error(sm.getString("endpoint.accept.fail"), t);
+ }
+
}
// The processor will recycle itself when it finishes
@@ -1039,7 +1101,7 @@
}
}
-
+
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-04-21 13:06:14 UTC (rev 588)
+++ trunk/webapps/docs/changelog.xml 2008-04-21 16:09:30 UTC (rev 589)
@@ -112,6 +112,10 @@
maxSavePostSize set to 0 for HTTP connectors should disable buffering done before SSL
handshake. (remm)
</fix>
+ <update>
+ Add reverse connection method (from the Java server to the proxy), which could
+ suppsedly provide better security, and could also improve quality of service. (remm)
+ </update>
</changelog>
</subsection>
<subsection name="Jasper">
16 years, 8 months
JBossWeb SVN: r588 - in trunk: res/jboss/org/apache/catalina/startup and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-21 09:06:14 -0400 (Mon, 21 Apr 2008)
New Revision: 588
Modified:
trunk/java/org/apache/catalina/core/StandardHost.java
trunk/res/jboss/org/apache/catalina/startup/catalina.properties
trunk/webapps/docs/changelog.xml
Log:
- Also use a system property for configClass.
Modified: trunk/java/org/apache/catalina/core/StandardHost.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardHost.java 2008-04-21 12:27:29 UTC (rev 587)
+++ trunk/java/org/apache/catalina/core/StandardHost.java 2008-04-21 13:06:14 UTC (rev 588)
@@ -94,7 +94,7 @@
* for deployed web applications.
*/
private String configClass =
- "org.apache.catalina.startup.ContextConfig";
+ System.getProperty("org.apache.catalina.core.StandardHost.configClass", "org.apache.catalina.startup.ContextConfig");
/**
@@ -139,12 +139,6 @@
/**
- * The live deploy flag for this Host.
- */
- private boolean liveDeploy = true;
-
-
- /**
* Unpack WARs property.
*/
private boolean unpackWARs = true;
Modified: trunk/res/jboss/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2008-04-21 12:27:29 UTC (rev 587)
+++ trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2008-04-21 13:06:14 UTC (rev 588)
@@ -4,6 +4,7 @@
org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true
org.apache.catalina.connector.Request.SESSION_ID_CHECK=true
org.apache.catalina.core.StandardHost.autoDeploy=false
+org.apache.catalina.core.StandardHost.configClass=org.jboss.web.tomcat.security.config.JBossContextConfig
org.apache.catalina.core.StandardHost.deployOnStartup=false
org.apache.catalina.core.StandardHost.deployXML=false
org.apache.catalina.core.StandardHost.startChildren=false
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-04-21 12:27:29 UTC (rev 587)
+++ trunk/webapps/docs/changelog.xml 2008-04-21 13:06:14 UTC (rev 588)
@@ -68,7 +68,8 @@
<bug>44392</bug>: HTML entities now handled correctly in SSI processing. (markt)
</fix>
<fix>
- Add system property for JBoss default allowing not starting the context in init. (remm)
+ Add system properties for JBoss default allowing not starting the context in init, and set
+ the configClass field. (remm)
</fix>
</changelog>
</subsection>
16 years, 8 months
JBossWeb SVN: r587 - in trunk: res/jboss/org/apache/catalina/startup and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-21 08:27:29 -0400 (Mon, 21 Apr 2008)
New Revision: 587
Modified:
trunk/java/org/apache/catalina/core/StandardHost.java
trunk/res/jboss/org/apache/catalina/startup/catalina.properties
trunk/webapps/docs/changelog.xml
trunk/webapps/docs/rewrite.xml
Log:
- Add JBoss default for not starting contexts in init (which would cause two errors instead of just one).
Modified: trunk/java/org/apache/catalina/core/StandardHost.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardHost.java 2008-04-17 19:23:46 UTC (rev 586)
+++ trunk/java/org/apache/catalina/core/StandardHost.java 2008-04-21 12:27:29 UTC (rev 587)
@@ -61,6 +61,8 @@
super();
pipeline.setBasic(new StandardHostValve());
+ startChildren =
+ Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardHost.startChildren", "true")).booleanValue();
}
Modified: trunk/res/jboss/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2008-04-17 19:23:46 UTC (rev 586)
+++ trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2008-04-21 12:27:29 UTC (rev 587)
@@ -6,6 +6,7 @@
org.apache.catalina.core.StandardHost.autoDeploy=false
org.apache.catalina.core.StandardHost.deployOnStartup=false
org.apache.catalina.core.StandardHost.deployXML=false
+org.apache.catalina.core.StandardHost.startChildren=false
# String cache configuration.
tomcat.util.buf.StringCache.byte.enabled=true
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-04-17 19:23:46 UTC (rev 586)
+++ trunk/webapps/docs/changelog.xml 2008-04-21 12:27:29 UTC (rev 587)
@@ -67,6 +67,9 @@
<fix>
<bug>44392</bug>: HTML entities now handled correctly in SSI processing. (markt)
</fix>
+ <fix>
+ Add system property for JBoss default allowing not starting the context in init. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Modified: trunk/webapps/docs/rewrite.xml
===================================================================
--- trunk/webapps/docs/rewrite.xml 2008-04-17 19:23:46 UTC (rev 586)
+++ trunk/webapps/docs/rewrite.xml 2008-04-21 12:27:29 UTC (rev 587)
@@ -97,12 +97,11 @@
where <em>NAME_OF_VARIABLE</em> can be a string taken
from the following list:
- <table>
- <columnspec><column width=".3"/><column width=".3"/>
- <column width=".3"/></columnspec>
+ <table border="1">
+
<tr>
<th>HTTP headers:</th> <th>connection & request:</th> <th></th>
- </tr>
+ </tr>
<tr>
<td>
16 years, 8 months
JBossWeb SVN: r586 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-17 15:23:46 -0400 (Thu, 17 Apr 2008)
New Revision: 586
Modified:
trunk/java/org/apache/catalina/ssi/SSIEcho.java
trunk/java/org/apache/catalina/ssi/SSIMediator.java
trunk/java/org/apache/catalina/ssi/SSIProcessor.java
trunk/webapps/docs/changelog.xml
Log:
- Port two Tomcat SSI patches.
Modified: trunk/java/org/apache/catalina/ssi/SSIEcho.java
===================================================================
--- trunk/java/org/apache/catalina/ssi/SSIEcho.java 2008-04-17 14:40:02 UTC (rev 585)
+++ trunk/java/org/apache/catalina/ssi/SSIEcho.java 2008-04-17 19:23:46 UTC (rev 586)
@@ -37,20 +37,14 @@
*/
public long process(SSIMediator ssiMediator, String commandName,
String[] paramNames, String[] paramValues, PrintWriter writer) {
- long lastModified = 0;
String encoding = DEFAULT_ENCODING;
+ String originalValue = null;
String errorMessage = ssiMediator.getConfigErrMsg();
for (int i = 0; i < paramNames.length; i++) {
String paramName = paramNames[i];
String paramValue = paramValues[i];
if (paramName.equalsIgnoreCase("var")) {
- String variableValue = ssiMediator.getVariableValue(
- paramValue, encoding);
- if (variableValue == null) {
- variableValue = MISSING_VARIABLE_VALUE;
- }
- writer.write(variableValue);
- lastModified = System.currentTimeMillis();
+ originalValue = paramValue;
} else if (paramName.equalsIgnoreCase("encoding")) {
if (isValidEncoding(paramValue)) {
encoding = paramValue;
@@ -63,7 +57,13 @@
writer.write(errorMessage);
}
}
- return lastModified;
+ String variableValue = ssiMediator.getVariableValue(
+ originalValue, encoding);
+ if (variableValue == null) {
+ variableValue = MISSING_VARIABLE_VALUE;
+ }
+ writer.write(variableValue);
+ return System.currentTimeMillis();
}
@@ -72,4 +72,4 @@
|| encoding.equalsIgnoreCase("entity")
|| encoding.equalsIgnoreCase("none");
}
-}
\ No newline at end of file
+}
Modified: trunk/java/org/apache/catalina/ssi/SSIMediator.java
===================================================================
--- trunk/java/org/apache/catalina/ssi/SSIMediator.java 2008-04-17 14:40:02 UTC (rev 585)
+++ trunk/java/org/apache/catalina/ssi/SSIMediator.java 2008-04-17 19:23:46 UTC (rev 586)
@@ -27,6 +27,7 @@
import org.apache.catalina.util.DateTool;
import org.apache.catalina.util.Strftime;
import org.apache.catalina.util.URLEncoder;
+import org.apache.tomcat.util.http.HttpMessages;
/**
* Allows the different SSICommand implementations to share data/talk to each
* other
@@ -205,10 +206,31 @@
* new resolved string.
*/
public String substituteVariables(String val) {
- // If it has no variable references then no work
+ // If it has no references or HTML entities then no work
// need to be done
- if (val.indexOf('$') < 0) return val;
+ if (val.indexOf('$') < 0 && val.indexOf('&') < 0) return val;
+
+ // HTML decoding
+ val.replace("<", "<");
+ val.replace(">", ">");
+ val.replace(""", "\"");
+ val.replace("&", "&");
+
StringBuffer sb = new StringBuffer(val);
+ int charStart = sb.indexOf("&#");
+ while (charStart > -1) {
+ int charEnd = sb.indexOf(";", charStart);
+ if (charEnd > -1) {
+ char c = (char) Integer.parseInt(
+ sb.substring(charStart + 2, charEnd));
+ sb.delete(charStart, charEnd + 1);
+ sb.insert(charStart, c);
+ charStart = sb.indexOf("&#");
+ } else {
+ break;
+ }
+ }
+
for (int i = 0; i < sb.length();) {
// Find the next $
for (; i < sb.length(); i++) {
@@ -279,8 +301,7 @@
} else if (encoding.equalsIgnoreCase("none")) {
retVal = value;
} else if (encoding.equalsIgnoreCase("entity")) {
- //Not sure how this is really different than none
- retVal = value;
+ retVal = HttpMessages.filter(value);
} else {
//This shouldn't be possible
throw new IllegalArgumentException("Unknown encoding: " + encoding);
@@ -328,4 +349,4 @@
retVal);
}
}
-}
\ No newline at end of file
+}
Modified: trunk/java/org/apache/catalina/ssi/SSIProcessor.java
===================================================================
--- trunk/java/org/apache/catalina/ssi/SSIProcessor.java 2008-04-17 14:40:02 UTC (rev 585)
+++ trunk/java/org/apache/catalina/ssi/SSIProcessor.java 2008-04-17 19:23:46 UTC (rev 586)
@@ -208,11 +208,10 @@
// Need to skip escaped characters
if (c == '\\' && !escaped) {
escaped = true;
- bIdx++;
continue;
}
+ if (c == '"' && !escaped) quotes++;
escaped = false;
- if (c == '"') quotes++;
}
}
}
@@ -322,4 +321,4 @@
protected boolean isQuote(char c) {
return c == '\'' || c == '\"' || c == '`';
}
-}
\ No newline at end of file
+}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-04-17 14:40:02 UTC (rev 585)
+++ trunk/webapps/docs/changelog.xml 2008-04-17 19:23:46 UTC (rev 586)
@@ -61,6 +61,12 @@
Better handling of lack of permission for context specific logging, and add permission
for reading the JDK logging.properties. (markt)
</fix>
+ <fix>
+ <bug>44391</bug>: Correct handling of escaped values in SSI processing. (markt)
+ </fix>
+ <fix>
+ <bug>44392</bug>: HTML entities now handled correctly in SSI processing. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
16 years, 8 months
JBossWeb SVN: r585 - trunk/java/org/jboss/web/cluster.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-17 10:40:02 -0400 (Thu, 17 Apr 2008)
New Revision: 585
Modified:
trunk/java/org/jboss/web/cluster/ClusterListener.java
Log:
- I did go through a lot of revisions, but this one using IntrospectionUtils seems to be the cleanest.
- Issue: No idea how to find the connect port on httpd. This could use explicit configuration maybe ...
Modified: trunk/java/org/jboss/web/cluster/ClusterListener.java
===================================================================
--- trunk/java/org/jboss/web/cluster/ClusterListener.java 2008-04-15 14:05:49 UTC (rev 584)
+++ trunk/java/org/jboss/web/cluster/ClusterListener.java 2008-04-17 14:40:02 UTC (rev 585)
@@ -24,6 +24,9 @@
package org.jboss.web.cluster;
+import java.net.InetAddress;
+import java.util.HashMap;
+
import org.apache.catalina.Container;
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.ContainerListener;
@@ -38,6 +41,7 @@
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.util.StringManager;
+import org.apache.tomcat.util.IntrospectionUtils;
import org.jboss.logging.Logger;
@@ -161,23 +165,56 @@
protected void config(Engine engine) {
System.out.println("Config: " + engine.getName());
- // FIXME: collect configuration from the connectors and service and call CONFIG
- Service service = engine.getService();
- Connector[] connectors = service.findConnectors();
+ // Collect configuration from the connectors and service and call CONFIG
+ Connector connector = findProxyConnector(engine.getService().findConnectors());
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("JVMRoute", engine.getJvmRoute());
+ boolean reverseConnection =
+ Boolean.TRUE.equals(IntrospectionUtils.getProperty(connector.getProtocolHandler(), "reverseConnection"));
+ boolean ssl =
+ Boolean.TRUE.equals(IntrospectionUtils.getProperty(connector.getProtocolHandler(), "SSLEnabled"));
+ boolean ajp = ((String) IntrospectionUtils.getProperty(connector.getProtocolHandler(), "name")).startsWith("ajp-");
+
+ if (reverseConnection) {
+ parameters.put("ReverseConnectionPort", "" + connector.getPort());
+ } else {
+ parameters.put("Host", getAddress(connector));
+ parameters.put("Port", "" + connector.getPort());
+ }
+ if (ajp) {
+ parameters.put("Type", "ajp");
+ } else if (ssl) {
+ parameters.put("Type", "https");
+ } else {
+ parameters.put("Type", "http");
+ }
+
+ // Send CONFIG request
+ // FIXME: By default, connect on localhost on some predefined port ?
}
protected void status(Engine engine) {
System.out.println("Status: " + engine.getName());
// FIXME: send STATUS
- Service service = engine.getService();
- Connector[] connectors = service.findConnectors();
+ Connector connector = findProxyConnector(engine.getService().findConnectors());
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("JVMRoute", engine.getJvmRoute());
+
+ // Send STATUS request
+ // FIXME: By default, connect on localhost on some predefined port ?
}
protected void addContext(Context context) {
System.out.println("Deploy context: " + context.getPath() + " to Host: " + context.getParent().getName() + " State: " + ((StandardContext) context).getState());
((Lifecycle) context).addLifecycleListener(this);
+
+ boolean started = (((StandardContext) context).getState() == 1);
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("JVMRoute", getJvmRoute(context));
+ parameters.put("context", ("".equals(context.getPath())) ? "/" : context.getPath());
+
// FIXME: send ENABLE-APP if state is started
}
@@ -185,6 +222,11 @@
protected void removeContext(Context context) {
System.out.println("Undeploy context: " + context.getPath() + " to Host: " + context.getParent().getName() + " State: " + ((StandardContext) context).getState());
((Lifecycle) context).removeLifecycleListener(this);
+
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("JVMRoute", getJvmRoute(context));
+ parameters.put("context", ("".equals(context.getPath())) ? "/" : context.getPath());
+
// FIXME: send REMOVE-APP
}
@@ -192,6 +234,11 @@
protected void startContext(Context context) {
Container parent = context.getParent();
System.out.println("Start context: " + context.getPath() + " to Host: " + parent.getName());
+
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("JVMRoute", getJvmRoute(context));
+ parameters.put("context", ("".equals(context.getPath())) ? "/" : context.getPath());
+
// FIXME: send ENABLE-APP
}
@@ -199,8 +246,50 @@
protected void stopContext(Context context) {
Container parent = context.getParent();
System.out.println("Stop context: " + context.getPath() + " to Host: " + parent.getName());
+
+ HashMap<String, String> parameters = new HashMap<String, String>();
+ parameters.put("JVMRoute", getJvmRoute(context));
+ parameters.put("context", ("".equals(context.getPath())) ? "/" : context.getPath());
+
// FIXME: send STOP-APP
}
+
+ protected String getJvmRoute(Context context) {
+ return ((Engine) context.getParent().getParent()).getJvmRoute();
+ }
+
+
+ protected Connector findProxyConnector(Connector[] connectors) {
+ int pos = 0;
+ int maxThreads = 0;
+ for (int i = 0; i < connectors.length; i++) {
+ if (connectors[i].getProtocol().startsWith("AJP")) {
+ // Return any AJP connector found
+ return connectors[i];
+ }
+ if (Boolean.TRUE.equals(IntrospectionUtils.getProperty(connectors[i].getProtocolHandler(), "reverseConnection"))) {
+ return connectors[i];
+ }
+ Integer mt = (Integer) IntrospectionUtils.getProperty(connectors[i].getProtocolHandler(), "maxThreads");
+ if (mt.intValue() > maxThreads) {
+ maxThreads = mt.intValue();
+ pos = i;
+ }
+ }
+ // If no AJP connector and no reverse, return the connector with the most threads
+ return connectors[pos];
+ }
+ protected String getAddress(Connector connector) {
+ InetAddress inetAddress =
+ (InetAddress) IntrospectionUtils.getProperty(connector.getProtocolHandler(), "address");
+ if (inetAddress == null) {
+ // FIXME: Return local address ? This is hard ...
+ return null;
+ } else {
+ return inetAddress.toString();
+ }
+ }
+
}
16 years, 8 months
JBossWeb SVN: r584 - in trunk: java/org/apache/el/parser and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2008-04-15 10:05:49 -0400 (Tue, 15 Apr 2008)
New Revision: 584
Modified:
trunk/java/org/apache/el/lang/ELArithmetic.java
trunk/java/org/apache/el/lang/ELSupport.java
trunk/java/org/apache/el/parser/AstNegative.java
trunk/webapps/docs/changelog.xml
Log:
- Improve number types handling in EL.
Modified: trunk/java/org/apache/el/lang/ELArithmetic.java
===================================================================
--- trunk/java/org/apache/el/lang/ELArithmetic.java 2008-04-15 13:54:17 UTC (rev 583)
+++ trunk/java/org/apache/el/lang/ELArithmetic.java 2008-04-15 14:05:49 UTC (rev 584)
@@ -110,12 +110,12 @@
public final static class DoubleDelegate extends ELArithmetic {
protected Number add(Number num0, Number num1) {
- // could only be one of these
- if (num0 instanceof BigDecimal) {
- return ((BigDecimal) num0).add(new BigDecimal(num1.doubleValue()));
- } else if (num1 instanceof BigDecimal) {
- return ((new BigDecimal(num0.doubleValue()).add((BigDecimal) num1)));
- }
+ // could only be one of these
+ if (num0 instanceof BigDecimal) {
+ return ((BigDecimal) num0).add(new BigDecimal(num1.doubleValue()));
+ } else if (num1 instanceof BigDecimal) {
+ return ((new BigDecimal(num0.doubleValue()).add((BigDecimal) num1)));
+ }
return new Double(num0.doubleValue() + num1.doubleValue());
}
@@ -123,7 +123,7 @@
if (num instanceof Double)
return num;
if (num instanceof BigInteger)
- return new BigDecimal((BigInteger) num);
+ return new BigDecimal((BigInteger) num);
return new Double(num.doubleValue());
}
@@ -140,22 +140,22 @@
}
protected Number subtract(Number num0, Number num1) {
- // could only be one of these
- if (num0 instanceof BigDecimal) {
- return ((BigDecimal) num0).subtract(new BigDecimal(num1.doubleValue()));
- } else if (num1 instanceof BigDecimal) {
- return ((new BigDecimal(num0.doubleValue()).subtract((BigDecimal) num1)));
- }
+ // could only be one of these
+ if (num0 instanceof BigDecimal) {
+ return ((BigDecimal) num0).subtract(new BigDecimal(num1.doubleValue()));
+ } else if (num1 instanceof BigDecimal) {
+ return ((new BigDecimal(num0.doubleValue()).subtract((BigDecimal) num1)));
+ }
return new Double(num0.doubleValue() - num1.doubleValue());
}
protected Number multiply(Number num0, Number num1) {
- // could only be one of these
- if (num0 instanceof BigDecimal) {
- return ((BigDecimal) num0).multiply(new BigDecimal(num1.doubleValue()));
- } else if (num1 instanceof BigDecimal) {
- return ((new BigDecimal(num0.doubleValue()).multiply((BigDecimal) num1)));
- }
+ // could only be one of these
+ if (num0 instanceof BigDecimal) {
+ return ((BigDecimal) num0).multiply(new BigDecimal(num1.doubleValue()));
+ } else if (num1 instanceof BigDecimal) {
+ return ((new BigDecimal(num0.doubleValue()).multiply((BigDecimal) num1)));
+ }
return new Double(num0.doubleValue() * num1.doubleValue());
}
@@ -164,8 +164,6 @@
|| obj1 instanceof Double
|| obj0 instanceof Float
|| obj1 instanceof Float
- || (obj0 != null && (Double.TYPE == obj0.getClass() || Float.TYPE == obj0.getClass()))
- || (obj1 != null && (Double.TYPE == obj1.getClass() || Float.TYPE == obj1.getClass()))
|| (obj0 instanceof String && ELSupport
.isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport
.isStringFloat((String) obj1)));
@@ -326,8 +324,11 @@
return (obj != null && isNumberType(obj.getClass()));
}
- public final static boolean isNumberType(final Class type) {
- return type == (java.lang.Long.class) || type == Long.TYPE || type == (java.lang.Double.class) || type == Double.TYPE || type == (java.lang.Byte.class) || type == Byte.TYPE || type == (java.lang.Short.class) || type == Short.TYPE || type == (java.lang.Integer.class) || type == Integer.TYPE || type == (java.lang.Float.class) || type == Float.TYPE || type == (java.math.BigInteger.class) || type == (java.math.BigDecimal.class);
+ public final static boolean isNumberType(final Class<?> type) {
+ return type == Long.TYPE || type == Double.TYPE ||
+ type == Byte.TYPE || type == Short.TYPE ||
+ type == Integer.TYPE || type == Float.TYPE ||
+ Number.class.isAssignableFrom(type);
}
/**
@@ -359,13 +360,12 @@
return coerce(ZERO);
}
- Class objType = obj.getClass();
- if (Character.class.equals(objType) || Character.TYPE == objType) {
+ if (obj instanceof Character) {
return coerce(new Short((short) ((Character) obj).charValue()));
}
throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, objType, "Number"));
+ obj, obj.getClass(), "Number"));
}
protected abstract Number coerce(final String str);
Modified: trunk/java/org/apache/el/lang/ELSupport.java
===================================================================
--- trunk/java/org/apache/el/lang/ELSupport.java 2008-04-15 13:54:17 UTC (rev 583)
+++ trunk/java/org/apache/el/lang/ELSupport.java 2008-04-15 14:05:49 UTC (rev 584)
@@ -164,7 +164,7 @@
if (obj == null || "".equals(obj)) {
return Boolean.FALSE;
}
- if (obj instanceof Boolean || obj.getClass() == Boolean.TYPE) {
+ if (obj instanceof Boolean) {
return (Boolean) obj;
}
if (obj instanceof String) {
@@ -187,7 +187,7 @@
return new Character((char) ((Number) obj).shortValue());
}
Class objType = obj.getClass();
- if (obj instanceof Character || objType == Character.TYPE) {
+ if (obj instanceof Character) {
return (Character) obj;
}
@@ -259,14 +259,13 @@
return coerceToNumber((Number) obj, type);
}
- Class objType = obj.getClass();
- if (Character.class.equals(objType) || Character.TYPE == objType) {
+ if (obj instanceof Character) {
return coerceToNumber(new Short((short) ((Character) obj)
.charValue()), type);
}
throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, objType, type));
+ obj, obj.getClass(), type));
}
protected final static Number coerceToNumber(final String val,
@@ -402,10 +401,7 @@
return (obj0 instanceof Double
|| obj1 instanceof Double
|| obj0 instanceof Float
- || obj1 instanceof Float
- || (obj0 != null && (Double.TYPE == obj0.getClass() || Float.TYPE == obj0
- .getClass())) || (obj1 != null && (Double.TYPE == obj1
- .getClass() || Float.TYPE == obj1.getClass())));
+ || obj1 instanceof Float);
}
public final static boolean isDoubleStringOp(final Object obj0,
@@ -424,17 +420,7 @@
|| obj0 instanceof Short
|| obj1 instanceof Short
|| obj0 instanceof Byte
- || obj1 instanceof Byte
- || (obj0 != null && (Long.TYPE == obj0.getClass()
- || Integer.TYPE == obj0.getClass()
- || Character.TYPE == obj0.getClass()
- || Short.TYPE == obj0.getClass() || Byte.TYPE == obj0
- .getClass())) || (obj0 != null && (Long.TYPE == obj0
- .getClass()
- || Integer.TYPE == obj0.getClass()
- || Character.TYPE == obj0.getClass()
- || Short.TYPE == obj0.getClass() || Byte.TYPE == obj0
- .getClass())));
+ || obj1 instanceof Byte);
}
public final static boolean isStringFloat(final String str) {
Modified: trunk/java/org/apache/el/parser/AstNegative.java
===================================================================
--- trunk/java/org/apache/el/parser/AstNegative.java 2008-04-15 13:54:17 UTC (rev 583)
+++ trunk/java/org/apache/el/parser/AstNegative.java 2008-04-15 14:05:49 UTC (rev 584)
@@ -43,23 +43,22 @@
}
return new Long(-Long.parseLong((String) obj));
}
- Class type = obj.getClass();
- if (obj instanceof Long || Long.TYPE == type) {
+ if (obj instanceof Long) {
return new Long(-((Long) obj).longValue());
}
- if (obj instanceof Double || Double.TYPE == type) {
+ if (obj instanceof Double) {
return new Double(-((Double) obj).doubleValue());
}
- if (obj instanceof Integer || Integer.TYPE == type) {
+ if (obj instanceof Integer) {
return new Integer(-((Integer) obj).intValue());
}
- if (obj instanceof Float || Float.TYPE == type) {
+ if (obj instanceof Float) {
return new Float(-((Float) obj).floatValue());
}
- if (obj instanceof Short || Short.TYPE == type) {
+ if (obj instanceof Short) {
return new Short((short) -((Short) obj).shortValue());
}
- if (obj instanceof Byte || Byte.TYPE == type) {
+ if (obj instanceof Byte) {
return new Byte((byte) -((Byte) obj).byteValue());
}
Long num = (Long) coerceToNumber(obj, Long.class);
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-04-15 13:54:17 UTC (rev 583)
+++ trunk/webapps/docs/changelog.xml 2008-04-15 14:05:49 UTC (rev 584)
@@ -112,6 +112,9 @@
<fix>
<bug>44428</bug>: NPE in function mapper. (markt)
</fix>
+ <fix>
+ Make number types handling more flexible in EL. (markt)
+ </fix>
</changelog>
</subsection>
</section>
16 years, 8 months