NPE when calling renderTemplate 2 times

Bug #534919 reported by Nicolas Leroux
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
play framework
Confirmed
Undecided
Guillaume Bort
1.0
Won't Fix
Undecided
Guillaume Bort
1.1
Confirmed
Undecided
Guillaume Bort

Bug Description

The PDF module use the renderTemplate method to render the template prior to transform it into a PDF that it then save on disk. Note that it can really well be the same problem with rendering one or two emails.

Once this is done I am rendering an HTML template so the user can see some HTML to download the file for example.

However, it seems that the template compiler has a state. I have a NPE. In order to fix the NPE, I had to remove the out argument from the renderArgs.data:

renderArgs.data.remove("out");

In the code that renders the template (Template.render), I can indeed see:

if (!args.containsKey("out")) {
            applyLayouts = true;
            layout.set(null);
            writer = new StringWriter();
            binding.setProperty("out", new PrintWriter(writer));
            currentTemplate.set(this);
        }

It seems that out is still there but already closed I think. Removing the

if (!args.containsKey("out"))

solves the problem and the tests pass. However, I was wondering for what reason the if line was there.

Revision history for this message
psartini (piero-sartini) wrote :

Maybe this is somehow related to #554762 ?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.