You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jos Snellings <Jo...@pandora.be> on 2009/12/04 15:15:36 UTC

URLConnectionUtils.closeLoudly()

Hi!

At the end of RESTController I get:

2009-12-04 14:57:26,014 ERROR http-8080-Processor20
org.apache.cocoon.sitemap.InvocationImpl/handle-errors - Error while
executing the sitemap. [request-uri=/editor/put/definition/1124]
java.lang.NullPointerException
        at
org.apache.cocoon.pipeline.util.URLConnectionUtils.closeQuietly(URLConnectionUtils.java:37)
        at
org.apache.cocoon.rest.controller.response.URLResponse.execute(URLResponse.java:91)
        at
org.apache.cocoon.rest.controller.SpringRESTController.invoke(SpringRESTController.java:88)
        at
org.apache.cocoon.controller.SpringControllerComponent.execute(SpringControllerComponent.java:50)
        at
org.apache.cocoon.pipeline.AbstractPipeline.invokeStarter(AbstractPipeline.java:147)
        at
org.apache.cocoon.pipeline.CachingPipeline.execute(CachingPipeline.java:126)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

It is certainly not closing a connection quietly :-) 

In URLResponse.java, is it possible that in execute()

servletConnection = this.url.openConnection(); is null?

Responses are like:
   if (action.equals("st")) return new
URLResponse("servlet:/thesaurusedit/stdemo",data);
            	if (action.equals("term")) return new
URLResponse("servlet:/edit/term", data);
            }
            
	return new URLResponse("servlet:editor/workspace", data);

Is there an obvious mistake I am making?

Thanks,
Jos


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: closeLoudly()

Posted by Jos Snellings <Jo...@pandora.be>.
OK, I attached the patch to the issue. I guess that is the right way.
Thanks for mentioning.
Jos



Re: closeLoudly()

Posted by David Crossley <cr...@apache.org>.
Jos Snellings wrote:
> I attached the patch. Is this the proper way to submit?
> Thanks, and please excuse me my ignorance. It is the first time.
> (first times can be traumatic, so far I am feeling well).

Thanks for your help.

As Simone suggested below, the issue tracker is way better
for many reasons.

Ideally then also follow up here by mentioning the issue number.

http://issues.apache.org/jira/browse/COCOON3
http://issues.apache.org/jira/browse/COCOON

> Jos Snellings wrote:
> > Thank you, Simone. I will do that.
> > 
> > Simone Tripodi wrote:
> > > Hi Jos,
> > > nice to meet you :) Usually suggestions of this kind have to be
> > > submitted by the issue tracker:
> > > 
> > > http://issues.apache.org/jira/browse/COCOON3
> > > 
> > > Make your own patch through the command line:
> > > 
> > > svn diff -x -u Main.java > arg-fix.patch
> > > 
> > > giving your patch file meaningful name.
> > > Goof job!
> > > Simo


Re: closeLoudly()

Posted by Simone Tripodi <si...@gmail.com>.
Hi Jos,
please don't think so, were are a community and we should help each other :)
In the past I did errors, but Reinhard and Steven kindly helped me as well ;)
Have a nice day,
Simo

On Sat, Dec 5, 2009 at 9:51 AM, Jos Snellings <Jo...@pandora.be> wrote:
> I attached the patch. Is this the proper way to submit?
> Thanks, and please excuse me my ignorance. It is the first time.
> (first times can be traumatic, so far I am feeling well).
>
> Jos
>
> On Sat, 2009-12-05 at 09:28 +0100, Jos Snellings wrote:
>> Thank you, Simone. I will do that.
>>
>> On Sat, 2009-12-05 at 09:21 +0100, Simone Tripodi wrote:
>> > Hi Jos,
>> > nice to meet you :) Usually suggestions of this kind have to be
>> > submitted by the issue tracker:
>> >
>> > http://issues.apache.org/jira/browse/COCOON3
>> >
>> > Make your own patch through the command line:
>> >
>> > svn diff -x -u Main.java > arg-fix.patch
>> >
>> > giving your patch file meaningful name.
>> > Goof job!
>> > Simo
>> >
>> > On Sat, Dec 5, 2009 at 8:29 AM, Jos Snellings <Jo...@pandora.be> wrote:
>> > > URLResponse.java:
>> > >
>> > > Modifying the finally-clause to remain silent:
>> > >
>> > > finally {
>> > >            if (servletConnection != null)
>> > > URLConnectionUtils.closeQuietly(servletConnection);
>> > >        }
>> > >
>> > > Jos
>> > >
>> > >
>> >
>> >
>> >
>>
>>
>>
>
>



-- 
http://www.google.com/profiles/simone.tripodi

Re: closeLoudly()

Posted by Jos Snellings <Jo...@pandora.be>.
I attached the patch. Is this the proper way to submit?
Thanks, and please excuse me my ignorance. It is the first time.
(first times can be traumatic, so far I am feeling well).

Jos

On Sat, 2009-12-05 at 09:28 +0100, Jos Snellings wrote:
> Thank you, Simone. I will do that.
> 
> On Sat, 2009-12-05 at 09:21 +0100, Simone Tripodi wrote:
> > Hi Jos,
> > nice to meet you :) Usually suggestions of this kind have to be
> > submitted by the issue tracker:
> > 
> > http://issues.apache.org/jira/browse/COCOON3
> > 
> > Make your own patch through the command line:
> > 
> > svn diff -x -u Main.java > arg-fix.patch
> > 
> > giving your patch file meaningful name.
> > Goof job!
> > Simo
> > 
> > On Sat, Dec 5, 2009 at 8:29 AM, Jos Snellings <Jo...@pandora.be> wrote:
> > > URLResponse.java:
> > >
> > > Modifying the finally-clause to remain silent:
> > >
> > > finally {
> > >            if (servletConnection != null)
> > > URLConnectionUtils.closeQuietly(servletConnection);
> > >        }
> > >
> > > Jos
> > >
> > >
> > 
> > 
> > 
> 
> 
> 


Re: closeLoudly()

Posted by Jos Snellings <Jo...@pandora.be>.
Thank you, Simone. I will do that.

On Sat, 2009-12-05 at 09:21 +0100, Simone Tripodi wrote:
> Hi Jos,
> nice to meet you :) Usually suggestions of this kind have to be
> submitted by the issue tracker:
> 
> http://issues.apache.org/jira/browse/COCOON3
> 
> Make your own patch through the command line:
> 
> svn diff -x -u Main.java > arg-fix.patch
> 
> giving your patch file meaningful name.
> Goof job!
> Simo
> 
> On Sat, Dec 5, 2009 at 8:29 AM, Jos Snellings <Jo...@pandora.be> wrote:
> > URLResponse.java:
> >
> > Modifying the finally-clause to remain silent:
> >
> > finally {
> >            if (servletConnection != null)
> > URLConnectionUtils.closeQuietly(servletConnection);
> >        }
> >
> > Jos
> >
> >
> 
> 
> 



Re: closeLoudly()

Posted by Simone Tripodi <si...@gmail.com>.
Hi Jos,
nice to meet you :) Usually suggestions of this kind have to be
submitted by the issue tracker:

http://issues.apache.org/jira/browse/COCOON3

Make your own patch through the command line:

svn diff -x -u Main.java > arg-fix.patch

giving your patch file meaningful name.
Goof job!
Simo

On Sat, Dec 5, 2009 at 8:29 AM, Jos Snellings <Jo...@pandora.be> wrote:
> URLResponse.java:
>
> Modifying the finally-clause to remain silent:
>
> finally {
>            if (servletConnection != null)
> URLConnectionUtils.closeQuietly(servletConnection);
>        }
>
> Jos
>
>



-- 
http://www.google.com/profiles/simone.tripodi

closeLoudly()

Posted by Jos Snellings <Jo...@pandora.be>.
URLResponse.java:

Modifying the finally-clause to remain silent:

finally {
            if (servletConnection != null)
URLConnectionUtils.closeQuietly(servletConnection);
        }

Jos


Re: URLConnectionUtils.closeLoudly()

Posted by Jos Snellings <Jo...@pandora.be>.
This is one for documentation:
from the examples:
URLResponse("servlet:/somewherehere",data)

does not work if you specify the root url.
Notation is absolute (with "servlet:")

if /somewherehere is in the same pipeline it works!

However, closeQuietly does not close quietly if the urlconnection is
null. The exception is thrown by the method and caught in the caller.
That is the silent part.

Jos


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: URLConnectionUtils.closeLoudly()

Posted by Steven Dolg <st...@indoqa.com>.
Jos Snellings schrieb:
> Hi!
>
> At the end of RESTController I get:
>
> 2009-12-04 14:57:26,014 ERROR http-8080-Processor20
> org.apache.cocoon.sitemap.InvocationImpl/handle-errors - Error while
> executing the sitemap. [request-uri=/editor/put/definition/1124]
> java.lang.NullPointerException
>         at
> org.apache.cocoon.pipeline.util.URLConnectionUtils.closeQuietly(URLConnectionUtils.java:37)
>         at
> org.apache.cocoon.rest.controller.response.URLResponse.execute(URLResponse.java:91)
>         at
> org.apache.cocoon.rest.controller.SpringRESTController.invoke(SpringRESTController.java:88)
>         at
> org.apache.cocoon.controller.SpringControllerComponent.execute(SpringControllerComponent.java:50)
>         at
> org.apache.cocoon.pipeline.AbstractPipeline.invokeStarter(AbstractPipeline.java:147)
>         at
> org.apache.cocoon.pipeline.CachingPipeline.execute(CachingPipeline.java:126)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>
> It is certainly not closing a connection quietly :-) 
>
> In URLResponse.java, is it possible that in execute()
>
> servletConnection = this.url.openConnection(); is null?
>
> Responses are like:
>    if (action.equals("st")) return new
> URLResponse("servlet:/thesaurusedit/stdemo",data);
>             	if (action.equals("term")) return new
> URLResponse("servlet:/edit/term", data);
>             }
>             
> 	return new URLResponse("servlet:editor/workspace", data);
>
> Is there an obvious mistake I am making?
>   

Hi,

the only difference I can spot is that your last URL does not include a 
leading slash after the protocol: "servlet:editor/workspace" instead of 
"servlet:/editor/workspace".
However throwing the NPE in closeQuietly() is a genuine bug IMO.

Does this happen in all cases of your "action" variable or only for a 
specific one?

IIRC, URL.openConnection will either return a connection of throw an 
exception.
Which would mean that openConnection fails and thus servletConnection 
remains null, which is then not handled correctly...


Steven


> Thanks,
> Jos
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: URLConnectionUtils.closeLoudly()

Posted by Jos Snellings <Jo...@pandora.be>.
You are right in "literal".equals(param), but that is not the source of
the problem. Like smoking, it is a habit I'd better give up ;-)
Jos

On Fri, 2009-12-04 at 15:29 +0100, Johannes Lichtenberger wrote:
> On Fri, 2009-12-04 at 15:15 +0100, Jos Snellings wrote:
> 
> [StackTrace]
> 
> > It is certainly not closing a connection quietly :-) 
> > 
> > In URLResponse.java, is it possible that in execute()
> > 
> > servletConnection = this.url.openConnection(); is null?
> > 
> > Responses are like:
> >    if (action.equals("st")) return new
> > URLResponse("servlet:/thesaurusedit/stdemo",data);
> >             	if (action.equals("term")) return new
> > URLResponse("servlet:/edit/term", data);
> >             }
> >             
> > 	return new URLResponse("servlet:editor/workspace", data);
> 
> Well, you know I'm not really familiar with cocoon, but I would replace
> action.equals("st") with "st".equals(action) and action.equals("term")
> equally, so you can't get NullPointerExceptions in this place (I know
> it's not the source of the problem).
> 
> greetings,
> Johannes  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: URLConnectionUtils.closeLoudly()

Posted by Johannes Lichtenberger <Jo...@uni-konstanz.de>.
On Fri, 2009-12-04 at 15:15 +0100, Jos Snellings wrote:

[StackTrace]

> It is certainly not closing a connection quietly :-) 
> 
> In URLResponse.java, is it possible that in execute()
> 
> servletConnection = this.url.openConnection(); is null?
> 
> Responses are like:
>    if (action.equals("st")) return new
> URLResponse("servlet:/thesaurusedit/stdemo",data);
>             	if (action.equals("term")) return new
> URLResponse("servlet:/edit/term", data);
>             }
>             
> 	return new URLResponse("servlet:editor/workspace", data);

Well, you know I'm not really familiar with cocoon, but I would replace
action.equals("st") with "st".equals(action) and action.equals("term")
equally, so you can't get NullPointerExceptions in this place (I know
it's not the source of the problem).

greetings,
Johannes  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org