You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/01/09 10:43:23 UTC

svn commit: r610323 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util: DefaultAddResource.java MyFacesResourceLoader.java ResourceLoader.java

Author: skitching
Date: Wed Jan  9 01:43:22 2008
New Revision: 610323

URL: http://svn.apache.org/viewvc?rev=610323&view=rev
Log:
TOMAHAWK-1174  fix ugly "broken pipe" log messages when using IE plus tomahawk components that use ExtensionsFilter, eg inputCalendar in popup mode.

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/MyFacesResourceLoader.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ResourceLoader.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java?rev=610323&r1=610322&r2=610323&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DefaultAddResource.java Wed Jan  9 01:43:22 2008
@@ -608,6 +608,10 @@
                     response, resourceUri);
             response.flushBuffer();
         }
+        catch (ResourceLoader.ClosedSocketException e)
+        {
+        	// the client closed the socket on us; just ignore.
+        }
         catch (ClassNotFoundException e)
         {
             log.error("Could not find class for name: " + className, e);

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/MyFacesResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/MyFacesResourceLoader.java?rev=610323&r1=610322&r2=610323&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/MyFacesResourceLoader.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/MyFacesResourceLoader.java Wed Jan  9 01:43:22 2008
@@ -103,7 +103,8 @@
      *     javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
      */
     public void serveResource(ServletContext context, HttpServletRequest request,
-            HttpServletResponse response, String resourceUri) throws IOException
+            HttpServletResponse response, String resourceUri)
+    	throws IOException, ResourceLoader.ClosedSocketException
     {
 		String[] uriParts = resourceUri.split("/", 2);
 
@@ -228,7 +229,8 @@
      * Copy the content of the specified input stream to the servlet response.
      */
     protected void writeResource(HttpServletRequest request, HttpServletResponse response,
-            InputStream in) throws IOException
+            InputStream in)
+        throws IOException, ResourceLoader.ClosedSocketException
     {
         ServletOutputStream out = response.getOutputStream();
         try
@@ -238,11 +240,33 @@
             {
                 out.write(buffer, 0, size);
             }
+    		out.close();
         }
-        finally
+        catch(IOException e)
         {
-            out.close();
+        	// This happens sometimes with Microsft Internet Explorer. It would
+        	// appear (guess) that when javascript creates multiple dom nodes
+        	// referring to the same remote resource then IE stupidly opens 
+        	// multiple sockets and requests that resource multiple times. But
+        	// when the first request completes, it then realises its stupidity
+        	// and forcibly closes all the other sockets. But here we are trying
+        	// to service those requests, and so get a "broken pipe" failure 
+        	// on write. The only thing to do here is to silently ignore the issue,
+        	// ie suppress the exception.
+
+        	try
+        	{
+        		out.close();
+        	}
+        	catch(Exception e2)
+        	{
+        		// Ignore; nothing we can do about this.
+        	}
+
+        	log.debug("Unable to send resource data to client", e);
+        	throw new ResourceLoader.ClosedSocketException();
         }
+        response.flushBuffer();
     }
 
     /**

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ResourceLoader.java?rev=610323&r1=610322&r2=610323&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ResourceLoader.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ResourceLoader.java Wed Jan  9 01:43:22 2008
@@ -33,7 +33,16 @@
  */
 public interface ResourceLoader
 {
-    /**
+	/**
+	 * Define an exception for reporting when a client requests a resource, but
+	 * then closes its socket before we finish sending it. In this case, the normal
+	 * behaviour is to not report an error; there is nothing wrong on this end. 
+	 */
+	public static class ClosedSocketException extends Exception
+	{
+	}
+
+	/**
      * Called by AddResource to render external resource data 
      * @param context TODO
      * @param request the request 
@@ -44,5 +53,6 @@
      * @throws IOException
      */
     public void serveResource(ServletContext context, HttpServletRequest request,
-            HttpServletResponse response, String resourceUri) throws IOException;
+            HttpServletResponse response, String resourceUri)
+    throws IOException, ClosedSocketException;
 }



Re: svn commit: r610323 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util: DefaultAddResource.java MyFacesResourceLoader.java ResourceLoader.java

Posted by Matthias Wessendorf <ma...@apache.org>.
sometimes I follow your mails, even I am really not interested in the content.
sometimes they are fun (knowing the physical facts ;-) )

-M

On Jan 9, 2008 11:10 PM, Martin Marinschek <ma...@gmail.com> wrote:
> We definitely appreciate this - this is what _The_ Apache Software
> Foundation is about ;)
>
> regards,
>
> Martin
>
>
>
> On Jan 9, 2008 7:16 PM, simon < simon.kitching@chello.at> wrote:
> >
> >
> >
> >
> > On Wed, 2008-01-09 at 10:56 +0100, Mario Ivankovits wrote:
> > > Hi Simon!
> > > >      public void serveResource(ServletContext context,
> HttpServletRequest request,
> > > > -            HttpServletResponse response, String resourceUri) throws
> IOException;
> > > > +            HttpServletResponse response, String resourceUri)
> > > > +    throws IOException, ClosedSocketException;
> > > >
> > >
> > > I am not sure if this is binary compatible. In any case, it would be
> > > safe to make CSE extend IOException (which in fact it is, no?) which
> > > will avoid the need to extend the interface.
> > > You still can catch that one, just ensure the ordering in the catch
> > > clause - but you know :-)
> >
> > Thanks Mario, you re quite right. I've now updated the code to be
> > binary-compatible.
> >
> > [I hope all of you out there appreciate that we are developing "in the
> > open", even though Mario and I sit about 1 metre apart :-]
> >
> > Thanks,
> > Simon
> >
> >
>
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Re: svn commit: r610323 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util: DefaultAddResource.java MyFacesResourceLoader.java ResourceLoader.java

Posted by Martin Marinschek <ma...@gmail.com>.
We definitely appreciate this - this is what _The_ Apache Software
Foundation is about ;)

regards,

Martin

On Jan 9, 2008 7:16 PM, simon <si...@chello.at> wrote:

>
> On Wed, 2008-01-09 at 10:56 +0100, Mario Ivankovits wrote:
> > Hi Simon!
> > >      public void serveResource(ServletContext context,
> HttpServletRequest request,
> > > -            HttpServletResponse response, String resourceUri) throws
> IOException;
> > > +            HttpServletResponse response, String resourceUri)
> > > +    throws IOException, ClosedSocketException;
> > >
> >
> > I am not sure if this is binary compatible. In any case, it would be
> > safe to make CSE extend IOException (which in fact it is, no?) which
> > will avoid the need to extend the interface.
> > You still can catch that one, just ensure the ordering in the catch
> > clause - but you know :-)
>
> Thanks Mario, you re quite right. I've now updated the code to be
> binary-compatible.
>
> [I hope all of you out there appreciate that we are developing "in the
> open", even though Mario and I sit about 1 metre apart :-]
>
> Thanks,
> Simon
>
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: svn commit: r610323 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util: DefaultAddResource.java MyFacesResourceLoader.java ResourceLoader.java

Posted by simon <si...@chello.at>.
On Wed, 2008-01-09 at 10:56 +0100, Mario Ivankovits wrote:
> Hi Simon!
> >      public void serveResource(ServletContext context, HttpServletRequest request,
> > -            HttpServletResponse response, String resourceUri) throws IOException;
> > +            HttpServletResponse response, String resourceUri)
> > +    throws IOException, ClosedSocketException;
> >   
> 
> I am not sure if this is binary compatible. In any case, it would be
> safe to make CSE extend IOException (which in fact it is, no?) which
> will avoid the need to extend the interface.
> You still can catch that one, just ensure the ordering in the catch
> clause - but you know :-)

Thanks Mario, you re quite right. I've now updated the code to be
binary-compatible.

[I hope all of you out there appreciate that we are developing "in the
open", even though Mario and I sit about 1 metre apart :-]

Thanks,
Simon


Re: svn commit: r610323 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util: DefaultAddResource.java MyFacesResourceLoader.java ResourceLoader.java

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Simon!
>      public void serveResource(ServletContext context, HttpServletRequest request,
> -            HttpServletResponse response, String resourceUri) throws IOException;
> +            HttpServletResponse response, String resourceUri)
> +    throws IOException, ClosedSocketException;
>   

I am not sure if this is binary compatible. In any case, it would be
safe to make CSE extend IOException (which in fact it is, no?) which
will avoid the need to extend the interface.
You still can catch that one, just ensure the ordering in the catch
clause - but you know :-)

Ciao,
Mario