Jump to content
We've recently updated our Privacy Statement, available here ×

Bug? Input stream has been finalized or forced closed without being explicitly closed


nanosk

Recommended Posts

Hello,

we're developing a Glassfish 3.1.x (JEE 6) based Application using "embedded" JasperReports (v4.5.1) to generate various Documents. Documents are typically created in two steps: firstly create the JasperPrint XML, secondly output the XML as a PDF to disk.

When I run the following test, I always get an exception printout in my logs

  1. create the JasperPrint, convert it to XML and store the XML in a database
  2. read the JasperPrintXML from the database and convert it into a JasperPrint instance again (using JRPrintXmlLoader.load(InputStream))
  3. shutdown the Glassfish Server

The relevant code for step 2 is attached.

I also attached the exception printed in my logs.

 

Debugging showed that JRXmlDigester#168 (mentioned in the StackTrace) loads the resource jasperreports.xsd into an InputStream. It seems this InputStream (which is wrapped into an InputSource) is never closed. Yet worse, if the conversion (Step 2) is executed multiple times, I end up with even more unclosed streams (all referring to the same resource).

Is it my fault or do I have to file a bug report?

 

Thanks for your time,

Pete

Code:
final InputStream is = new ByteArrayInputStream(job.getJasperData().getBytes());final JasperPrint jasperPrint;try {	jasperPrint = JRPrintXmlLoader.load(is);} catch (final JRException e) {	throw new PrintException(e, PrintExceptionReason.READING_JASPER_XML_FAILED, job.getBusinessCaseId());} finally {	try {		is.close();	} catch (final IOException e) {		logger.warn("could not close input stream of document for business case {}", job.getBusinessCaseId());	}}return jasperPrint;
Link to comment
Share on other sites

  • 1 month later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...