Re: URLConnectionUtils.closeLoudly()

2009-12-04 Thread Johannes Lichtenberger
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-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org



Re: URLConnectionUtils.closeLoudly()

2009-12-04 Thread Steven Dolg

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-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org


  



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



Re: URLConnectionUtils.closeLoudly()

2009-12-04 Thread Jos Snellings
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-unsubscr...@cocoon.apache.org
 For additional commands, e-mail: users-h...@cocoon.apache.org
 
 



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



Re: URLConnectionUtils.closeLoudly()

2009-12-04 Thread Jos Snellings
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-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org