Add in voted on fixes
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Oct 2007 02:16:41 +0000 (02:16 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Oct 2007 02:16:41 +0000 (02:16 +0000)
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

STATUS
java/org/apache/catalina/loader/mbeans-descriptors.xml
java/org/apache/catalina/startup/ConnectorCreateRule.java
java/org/apache/catalina/tribes/membership/McastServiceImpl.java
java/org/apache/jasper/compiler/Compiler.java
java/org/apache/tomcat/util/net/NioBlockingSelector.java
java/org/apache/tomcat/util/net/NioSelectorPool.java
java/org/apache/tomcat/util/net/SecureNioChannel.java
webapps/docs/changelog.xml

diff --git a/STATUS b/STATUS
index 9c8d076..6fb8d6a 100644 (file)
--- 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
index d361496..19a80ef 100644 (file)
@@ -72,4 +72,9 @@
                 group="Loader"
                  type="org.apache.catalina.loader.WebappClassLoader" />
 
+  <mbean         name="VirtualWebappLoader"
+          description="Extension of the webapp class loader with additional features"
+               domain="Catalina"
+                group="Loader"
+                 type="org.apache.catalina.loader.VirtualWebappLoader" />
 </mbeans-descriptors>
index d4bd869..06d75bc 100644 (file)
@@ -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.");
+        }
     }
 
 
index e5ae5ab..c17affa 100644 (file)
@@ -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 <b>membership</b> 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())
index fbe95a0..8b4e32f 100644 (file)
@@ -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
      */
index eb49ba2..7a9d366 100644 (file)
@@ -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
index 5562b4d..f5852a0 100644 (file)
@@ -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;
index b53ceef..1bc1780 100644 (file)
@@ -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;
+        }
     }
     
     /**
index 0f8578b..0435155 100644 (file)
   </subsection>
   <subsection name="Catalina">
     <changelog>
+      <fix><bug>43653</bug>Fix SSL buffer mixup when response is unable to write more than socket buffer can handle</fix>
+      <fix><bug>43643</bug>If connector doesn't support external executor, display warning</fix>
+      <fix><bug>43641</bug>Property bind multicast address for cluster membership</fix>
+      <fix><bug>42693</bug> Fix JSP compiler bug</fix>
+      <update>Add mbean descriptor for virtual webapp loader</update>
       <fix><bug>43487</bug>
         Fix request processing stats
       </fix>