https://issues.apache.org/bugzilla/show_bug.cgi?id=53046

--- Comment #3 from Dominik Stadler <[email protected]> 2012-04-11 
15:19:12 UTC ---
I have worked around this via the following helper method which iterates over
any image that was used for creating a PDF with FOP and tries to get the
related source and closes it.

    public static void cleanupFOAgentImages(final Collection<String> images,
final FOUserAgent foUserAgent) {
        for(String image : images) {
            if(logger.isLoggable(Level.FINE)) {
                logger.fine("Try to remove file: file:///" + image + " from FOP
image session context."); //$NON-NLS-1$ //$NON-NLS-2$
            }

            ImageSessionContext imageCtx =
foUserAgent.getImageSessionContext();
            if(imageCtx instanceof AbstractImageSessionContext) {
                AbstractImageSessionContext aImageCtx =
(AbstractImageSessionContext)imageCtx;
                Source src = aImageCtx.getSource(BaseConstants.FILE_PROTOCOL +
image);

                // use helper method which does the correct close for all types
of Source, e.g. StreamSource, ImageSource, ...
                // this also handles src==null gracefully.
                ImageUtil.closeQuietly(src);
            }
        }
    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to