You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Moritz Gmelin <mo...@gmx.de> on 2009/06/01 22:49:40 UTC

[T5.1] NPE in ResponseCompressionAnalyzerImpl.isCompressable

Hi,

we just tried porting  a larger application from 5.0.18 to 5.1.0.5.

One thing is causing troubles though. We use redirection in some cases  
to bring the user back to the start page if an error occurs.

This is how we do it in T5.1 (code from a sample Page to reproduce the  
NPE in a clean application)


	@Inject
	private Response response;
	
	@Inject
	private PageRenderLinkSource linkSource;

	@BeforeRenderTemplate
	public void beforeRender()
	{
		try
		{
			response.sendRedirect(linkSource.createPageRenderLink(
			Page1.class));
		}
		catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

And this is the exception we get.

java.lang.NullPointerException
	 
org 
.apache 
.tapestry5 
.internal 
.services 
.ResponseCompressionAnalyzerImpl 
.isCompressable(ResponseCompressionAnalyzerImpl.java:65)
	 
$ 
ResponseCompressionAnalyzer_1219d91934e 
.isCompressable($ResponseCompressionAnalyzer_1219d91934e.java)
	 
org 
.apache 
.tapestry5 
.internal 
.gzip 
.BufferedGZipOutputStream 
.openResponseOutputStream(BufferedGZipOutputStream.java:77)
	 
org 
.apache 
.tapestry5 
.internal 
.gzip 
.BufferedGZipOutputStream 
.checkForCutover(BufferedGZipOutputStream.java:70)
	 
org 
.apache 
.tapestry5 
.internal 
.gzip.BufferedGZipOutputStream.write(BufferedGZipOutputStream.java:116)
	sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
	sun.nio.cs.StreamEncoder$CharsetSE.implClose(StreamEncoder.java:427)
	sun.nio.cs.StreamEncoder.close(StreamEncoder.java:160)
	java.io.OutputStreamWriter.close(OutputStreamWriter.java:222)
	java.io.BufferedWriter.close(BufferedWriter.java:250)
	java.io.PrintWriter.close(PrintWriter.java:287)
	 
org 
.apache 
.tapestry5 
.internal 
.services 
.PageResponseRendererImpl 
.renderPageResponse(PageResponseRendererImpl.java:80)
	 
$ 
PageResponseRenderer_1219d91936f 
.renderPageResponse($PageResponseRenderer_1219d91936f.java)
	 
org 
.apache 
.tapestry5 
.internal 
.services 
.DefaultRequestExceptionHandler 
.handleRequestException(DefaultRequestExceptionHandler.java:77)
	 
$ 
RequestExceptionHandler_1219d919358 
.handleRequestException($RequestExceptionHandler_1219d919358.java)
	 
org 
.apache 
.tapestry5 
.internal.services.RequestErrorFilter.service(RequestErrorFilter.java: 
42)
	$RequestHandler_1219d91935a.service($RequestHandler_1219d91935a.java)
	org.apache.tapestry5.services.TapestryModule 
$4.service(TapestryModule.java:778)
	$RequestHandler_1219d91935a.service($RequestHandler_1219d91935a.java)
	org.apache.tapestry5.services.TapestryModule 
$3.service(TapestryModule.java:767)
	$RequestHandler_1219d91935a.service($RequestHandler_1219d91935a.java)
	 
org 
.apache 
.tapestry5 
.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
	$RequestHandler_1219d91935a.service($RequestHandler_1219d91935a.java)
	org.apache.tapestry5.internal.services.CheckForUpdatesFilter 
$2.invoke(CheckForUpdatesFilter.java:90)
	org.apache.tapestry5.internal.services.CheckForUpdatesFilter 
$2.invoke(CheckForUpdatesFilter.java:81)
	 
org 
.apache 
.tapestry5 
.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
	 
org 
.apache 
.tapestry5 
.internal 
.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:103)
	$RequestHandler_1219d91935a.service($RequestHandler_1219d91935a.java)
	$RequestHandler_1219d919350.service($RequestHandler_1219d919350.java)
	org.apache.tapestry5.services.TapestryModule 
$HttpServletRequestHandlerTerminator.service(TapestryModule.java:197)
	org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java: 
53)
	 
$ 
HttpServletRequestHandler_1219d919352 
.service($HttpServletRequestHandler_1219d919352.java)
	 
org 
.apache 
.tapestry5 
.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java: 
62)
	 
$ 
HttpServletRequestFilter_1219d91934f 
.service($HttpServletRequestFilter_1219d91934f.java)
	 
$ 
HttpServletRequestHandler_1219d919352 
.service($HttpServletRequestHandler_1219d919352.java)
	org.apache.tapestry5.services.TapestryModule 
$2.service(TapestryModule.java:726)
	 
$ 
HttpServletRequestHandler_1219d919352 
.service($HttpServletRequestHandler_1219d919352.java)
	 
$ 
HttpServletRequestHandler_1219d91934d 
.service($HttpServletRequestHandler_1219d91934d.java)
	org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:127)

Using jetty. the redirect works but is ugly in the logs. In tomcat,  
the Exception is presented to the user as a tomcat exception.

What can we do other than switching off compression all the way?

M.



Re: [T5.1] NPE in ResponseCompressionAnalyzerImpl.isCompressable

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Jun 2, 2009 at 3:13 AM, Moritz Gmelin <mo...@gmx.de> wrote:
> Hi,

Hi!

> back to my original question: Is this NPE a bug in T5.1 or is redirection
> not working at all?

You shouldn't do redirection that way, but a NPE inside Tapestry code
surely looks like a bug.

-- 
Thiago

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


Re: [T5.1] NPE in ResponseCompressionAnalyzerImpl.isCompressable

Posted by Moritz Gmelin <mo...@gmx.de>.
Hi,

back to my original question: Is this NPE a bug in T5.1 or is  
redirection not working at all?

M.

Am 01.06.2009 um 23:31 schrieb Thiago H. de Paula Figueiredo:

> Em Mon, 01 Jun 2009 18:23:04 -0300, Moritz Gmelin <moritz.gmelin@gmx.de 
> > escreveu:
>
>> Thanks for this try,
>
> Ooops, my mistake. You can return a Class or page instance only in  
> onActivate().
>
> Try
>
> 	public Class onActivate()
> 	{
> 		....
> 		....
> 		if (needsToRedirect) {
> 			return Start.class;
> 		}
> 		else {
> 			return null;
> 		}
> 	}
>
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


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


Re: [T5.1] NPE in ResponseCompressionAnalyzerImpl.isCompressable

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 01 Jun 2009 18:23:04 -0300, Moritz Gmelin <mo...@gmx.de>  
escreveu:

> Thanks for this try,

Ooops, my mistake. You can return a Class or page instance only in  
onActivate().

Try

  	public Class onActivate()
  	{
  		....
  		....
		if (needsToRedirect) {
			return Start.class;
		}
		else {
			return null;
		}
  	}

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: [T5.1] NPE in ResponseCompressionAnalyzerImpl.isCompressable

Posted by Moritz Gmelin <mo...@gmx.de>.
Thanks for this try,

but


	@BeginRender
	public Class beginRender()
	{
		....
		....
		return Start.class;
	}

gives another Exception

org.apache.tapestry5.internal.services.RenderQueueException: Render  
queue error in BeginRender[ExceptionReport]:
The return value from a render phase event method was not compatible  
the expected return type of java.lang.Boolean. You should change the  
method to return the correct type.

I know that I can return Page classes from event handler methods. But  
it does not seem to work from RenderPhaseMethods.

Any other ideas?

Thanks

Moritz

Am 01.06.2009 um 23:05 schrieb Thiago H. de Paula Figueiredo:

> Em Mon, 01 Jun 2009 17:49:40 -0300, Moritz Gmelin <moritz.gmelin@gmx.de 
> > escreveu:
>
>> Hi,
>
> Hi!
>
> You could just return Page1.class in beforeRender() or onActivate()  
> to redirect instead of injecting Response and return null to  
> continue processing the page without any redirection. This works in  
> any Tapestry version. This is documented at http://tapestry.apache.org/tapestry5.1/guide/pagenav.html 
> .
>
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5.1] NPE in ResponseCompressionAnalyzerImpl.isCompressable

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 01 Jun 2009 17:49:40 -0300, Moritz Gmelin <mo...@gmx.de>  
escreveu:

> Hi,

Hi!

You could just return Page1.class in beforeRender() or onActivate() to  
redirect instead of injecting Response and return null to continue  
processing the page without any redirection. This works in any Tapestry  
version. This is documented at  
http://tapestry.apache.org/tapestry5.1/guide/pagenav.html.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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