From: fhanik Date: Fri, 19 Oct 2007 02:16:41 +0000 (+0000) Subject: Add in voted on fixes X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=403dba3c91960c6297bfdfa278c300f488348147;p=tomcat7.0 Add in voted on fixes Fix 43653: SSL buffer mixup when response is unable to write more than socket buffer can handle Fix 43643: If connector doesn't support external executor, display warning Fix 43641: Property bind multicast address for cluster membership Fix 42693: JSP compiler bug with recursive tag files Update: Add mbean descriptor for virtual webapp loader git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@586228 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 9c8d07671..6fb8d6a65 100644 --- a/STATUS +++ b/STATUS @@ -31,16 +31,6 @@ PATCHES PROPOSED TO BACKPORT: http://people.apache.org/~fhanik/patches/digester-attribute-warnings.patch +1: fhanik, yoavs -1: - -* Add missing mbean descriptor - http://people.apache.org/~fhanik/patches/loader-mbean.patch - +1: fhanik,funkman,yoavs - -1: - -* Proposed solution to http://issues.apache.org/bugzilla/show_bug.cgi?id=42693 - Patch: http://issues.apache.org/bugzilla/attachment.cgi?id=20940 - +1: fhanik,funkman, yoavs - -1: * IcedTea support. Upcoming Linux distributions will package a (working) open source JRE, available in /usr. As a result, it could now be possible to use a "/usr/bin/java" binary @@ -70,21 +60,7 @@ PATCHES PROPOSED TO BACKPORT: -1: 0: yoavs -* Fix multicasting bind address on multihomed computers - http://issues.apache.org/bugzilla/show_bug.cgi?id=43641 - +1: fhanik, pero, yoavs, markt - -1: - -* Warn if connector can not use external executors - http://issues.apache.org/bugzilla/show_bug.cgi?id=43643 - +1: fhanik, pero, yoavs, markt - -1: - -* Fix SSL buffer bug - http://issues.apache.org/bugzilla/show_bug.cgi?id=43653 - +1: fhanik, yoavs, markt - -1: - + * Add a working ANT script that signs and publishes JARs to a maven repo http://people.apache.org/~fhanik/patches/maven-publish.patch +1: fhanik, yoavs diff --git a/java/org/apache/catalina/loader/mbeans-descriptors.xml b/java/org/apache/catalina/loader/mbeans-descriptors.xml index d361496c4..19a80ef8a 100644 --- a/java/org/apache/catalina/loader/mbeans-descriptors.xml +++ b/java/org/apache/catalina/loader/mbeans-descriptors.xml @@ -72,4 +72,9 @@ group="Loader" type="org.apache.catalina.loader.WebappClassLoader" /> + diff --git a/java/org/apache/catalina/startup/ConnectorCreateRule.java b/java/org/apache/catalina/startup/ConnectorCreateRule.java index d4bd86940..06d75bc6b 100644 --- a/java/org/apache/catalina/startup/ConnectorCreateRule.java +++ b/java/org/apache/catalina/startup/ConnectorCreateRule.java @@ -27,6 +27,8 @@ import org.apache.catalina.Service; import org.apache.catalina.Executor; import org.apache.tomcat.util.IntrospectionUtils; import java.lang.reflect.Method; +import org.apache.juli.logging.LogFactory; +import org.apache.juli.logging.Log; /** @@ -35,7 +37,7 @@ import java.lang.reflect.Method; public class ConnectorCreateRule extends Rule { - + protected static Log log = LogFactory.getLog(ConnectorCreateRule.class); // --------------------------------------------------------- Public Methods @@ -58,7 +60,11 @@ public class ConnectorCreateRule extends Rule { public void _setExecutor(Connector con, Executor ex) throws Exception { Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setExecutor",new Class[] {java.util.concurrent.Executor.class}); - m.invoke(con.getProtocolHandler(),new Object[] {ex}); + if (m!=null) { + m.invoke(con.getProtocolHandler(), new Object[] {ex}); + }else { + log.warn("Connector ["+con+"] does not support external executors. Method setExecutor(java.util.concurrent.Executor) not found."); + } } diff --git a/java/org/apache/catalina/tribes/membership/McastServiceImpl.java b/java/org/apache/catalina/tribes/membership/McastServiceImpl.java index e5ae5ab87..c17affa1c 100644 --- a/java/org/apache/catalina/tribes/membership/McastServiceImpl.java +++ b/java/org/apache/catalina/tribes/membership/McastServiceImpl.java @@ -29,6 +29,7 @@ import java.util.Arrays; import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.Member; import org.apache.catalina.tribes.MembershipListener; +import java.net.BindException; /** * A membership implementation using simple multicast. @@ -182,8 +183,22 @@ public class McastServiceImpl } protected void setupSocket() throws IOException { - if (mcastBindAddress != null) socket = new MulticastSocket(new InetSocketAddress(mcastBindAddress, port)); - else socket = new MulticastSocket(port); + if (mcastBindAddress != null) { + try { + log.info("Attempting to bind the multicast socket to "+address+":"+port); + socket = new MulticastSocket(new InetSocketAddress(address,port)); + } catch (BindException e) { + /* + * On some plattforms (e.g. Linux) it is not possible to bind + * to the multicast address. In this case only bind to the + * port. + */ + log.info("Binding to multicast address, failed. Binding to port only."); + socket = new MulticastSocket(port); + } + } else { + socket = new MulticastSocket(port); + } socket.setLoopbackMode(false); //hint that we don't need loop back messages if (mcastBindAddress != null) { if(log.isInfoEnabled()) diff --git a/java/org/apache/jasper/compiler/Compiler.java b/java/org/apache/jasper/compiler/Compiler.java index fbe95a051..8b4e32fdc 100644 --- a/java/org/apache/jasper/compiler/Compiler.java +++ b/java/org/apache/jasper/compiler/Compiler.java @@ -141,23 +141,9 @@ public abstract class Compiler { ctxt.checkOutputDir(); String javaFileName = ctxt.getServletJavaFileName(); - ServletWriter writer = null; + ServletWriter writer = null; try { - // Setup the ServletWriter - String javaEncoding = ctxt.getOptions().getJavaEncoding(); - OutputStreamWriter osw = null; - - try { - osw = new OutputStreamWriter( - new FileOutputStream(javaFileName), javaEncoding); - } catch (UnsupportedEncodingException ex) { - errDispatcher.jspError("jsp.error.needAlternateJavaEncoding", - javaEncoding); - } - - writer = new ServletWriter(new PrintWriter(osw)); - ctxt.setWriter(writer); // Reset the temporary variable counter for the generator. JspUtil.resetTemporaryVariableName(); @@ -168,6 +154,7 @@ public abstract class Compiler { if (ctxt.isPrototypeMode()) { // generate prototype .java file for the tag file + writer = setupContextWriter(javaFileName); Generator.generate(writer, this, pageNodes); writer.close(); writer = null; @@ -207,6 +194,7 @@ public abstract class Compiler { ELFunctionMapper.map(this, pageNodes); // generate servlet .java file + writer = setupContextWriter(javaFileName); Generator.generate(writer, this, pageNodes); writer.close(); writer = null; @@ -259,6 +247,26 @@ public abstract class Compiler { return smapStr; } + private ServletWriter setupContextWriter(String javaFileName) + throws FileNotFoundException, JasperException { + ServletWriter writer; + // Setup the ServletWriter + String javaEncoding = ctxt.getOptions().getJavaEncoding(); + OutputStreamWriter osw = null; + + try { + osw = new OutputStreamWriter( + new FileOutputStream(javaFileName), javaEncoding); + } catch (UnsupportedEncodingException ex) { + errDispatcher.jspError("jsp.error.needAlternateJavaEncoding", + javaEncoding); + } + + writer = new ServletWriter(new PrintWriter(osw)); + ctxt.setWriter(writer); + return writer; + } + /** * Compile the servlet from .java file to .class file */ diff --git a/java/org/apache/tomcat/util/net/NioBlockingSelector.java b/java/org/apache/tomcat/util/net/NioBlockingSelector.java index eb49ba240..7a9d36676 100644 --- a/java/org/apache/tomcat/util/net/NioBlockingSelector.java +++ b/java/org/apache/tomcat/util/net/NioBlockingSelector.java @@ -47,10 +47,6 @@ public class NioBlockingSelector { boolean timedout = false; int keycount = 1; //assume we can write long time = System.currentTimeMillis(); //start the timeout timer - if (socket.getBufHandler().getWriteBuffer() != buf) { - socket.getBufHandler().getWriteBuffer().put(buf); - buf = socket.getBufHandler().getWriteBuffer(); - } try { while ( (!timedout) && buf.hasRemaining()) { if (keycount > 0) { //only write if we were registered for a write diff --git a/java/org/apache/tomcat/util/net/NioSelectorPool.java b/java/org/apache/tomcat/util/net/NioSelectorPool.java index 5562b4d9c..f5852a012 100644 --- a/java/org/apache/tomcat/util/net/NioSelectorPool.java +++ b/java/org/apache/tomcat/util/net/NioSelectorPool.java @@ -139,10 +139,6 @@ public class NioSelectorPool { boolean timedout = false; int keycount = 1; //assume we can write long time = System.currentTimeMillis(); //start the timeout timer - if ( socket.getBufHandler().getWriteBuffer()!= buf ) { - socket.getBufHandler().getWriteBuffer().put(buf); - buf = socket.getBufHandler().getWriteBuffer(); - } try { while ( (!timedout) && buf.hasRemaining() ) { int cnt = 0; diff --git a/java/org/apache/tomcat/util/net/SecureNioChannel.java b/java/org/apache/tomcat/util/net/SecureNioChannel.java index b53ceefe5..1bc178042 100644 --- a/java/org/apache/tomcat/util/net/SecureNioChannel.java +++ b/java/org/apache/tomcat/util/net/SecureNioChannel.java @@ -392,38 +392,44 @@ public class SecureNioChannel extends NioChannel { * @todo Implement this java.nio.channels.WritableByteChannel method */ public int write(ByteBuffer src) throws IOException { - //make sure we can handle expand, and that we only use on buffer - if ( src != bufHandler.getWriteBuffer() ) throw new IllegalArgumentException("You can only write using the application write buffer provided by the handler."); - //are we closing or closed? - if ( closing || closed) throw new IOException("Channel is in closing state."); - - //the number of bytes written - int written = 0; - - if (!flush(netOutBuffer)) { - //we haven't emptied out the buffer yet + if ( src == this.netOutBuffer ) { + //we can get here through a recursive call + //by using the NioBlockingSelector + int written = sc.write(src); return written; - } - - /* - * The data buffer is empty, we can reuse the entire buffer. - */ - netOutBuffer.clear(); - - SSLEngineResult result = sslEngine.wrap(src, netOutBuffer); - written = result.bytesConsumed(); - netOutBuffer.flip(); - - if (result.getStatus() == Status.OK) { - if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) tasks(); } else { - throw new IOException("Unable to wrap data, invalid engine state: " +result.getStatus()); - } - - //force a flush - flush(netOutBuffer); - - return written; + //make sure we can handle expand, and that we only use on buffer + if ( src != bufHandler.getWriteBuffer() ) throw new IllegalArgumentException("You can only write using the application write buffer provided by the handler."); + //are we closing or closed? + if ( closing || closed) throw new IOException("Channel is in closing state."); + + //the number of bytes written + int written = 0; + + if (!flush(netOutBuffer)) { + //we haven't emptied out the buffer yet + return written; + } + + /* + * The data buffer is empty, we can reuse the entire buffer. + */ + netOutBuffer.clear(); + + SSLEngineResult result = sslEngine.wrap(src, netOutBuffer); + written = result.bytesConsumed(); + netOutBuffer.flip(); + + if (result.getStatus() == Status.OK) { + if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) tasks(); + } else { + throw new IOException("Unable to wrap data, invalid engine state: " +result.getStatus()); + } + + //force a flush + flush(netOutBuffer); + return written; + } } /** diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 0f8578b31..043515522 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -42,6 +42,11 @@ + 43653Fix SSL buffer mixup when response is unable to write more than socket buffer can handle + 43643If connector doesn't support external executor, display warning + 43641Property bind multicast address for cluster membership + 42693 Fix JSP compiler bug + Add mbean descriptor for virtual webapp loader 43487 Fix request processing stats