You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by "Andreas B. (JIRA)" <ji...@apache.org> on 2012/09/10 15:38:08 UTC

[jira] [Created] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Andreas B. created SANTUARIO-344:
------------------------------------

             Summary: XMLSignature keeps file-handle on xml-file
                 Key: SANTUARIO-344
                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
             Project: Santuario
          Issue Type: Bug
          Components: Java
    Affects Versions: Java 1.5.1
         Environment: Windows (XP, 7)
            Reporter: Andreas B.
            Assignee: Colm O hEigeartaigh
            Priority: Minor


When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).

I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.


Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457916#comment-13457916 ] 

Colm O hEigeartaigh edited comment on SANTUARIO-344 at 9/19/12 3:35 AM:
------------------------------------------------------------------------


Could you put a breakpoint in XMLSignatureInput.getBytesFromInputStream() and see if an exception is being thrown (possibly in JavaUtils.getBytesFromStream) before inputOctetStreamProxy.close(); is called?

I've committed some code to close the internal InputStream of XMLSignatureInput on an exception - possibly this will help. I also noticed that the convertToNodes method just nulls the inputStream instead of explicitly closing it first - I have also fixed this. Could you try with a 1.5.3-SNAPSHOT build (once it picks up this fix) to see if this fixes the problem?

Colm.
                
      was (Author: coheigea):
    
Could you put a breakpoint in XMLSignatureInput.getBytesFromInputStream() and see if an exception is being thrown (possibly in JavaUtils.getBytesFromStream) before inputOctetStreamProxy.close(); is called?

I've committed some code to close the internal InputStream of XMLSignatureInput on an exception - possibly this will help.

Colm.
                  
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Colm O hEigeartaigh resolved SANTUARIO-344.
-------------------------------------------

    Resolution: Fixed
    
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.3
>
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459670#comment-13459670 ] 

Andreas B. commented on SANTUARIO-344:
--------------------------------------

Thanks, Colm - it works now! (tested with xmlsec-1.5.3-20120920.102627-14.jar)

Can you say, when the next official release, containing this fix, will be available?
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.3
>
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457875#comment-13457875 ] 

Andreas B. edited comment on SANTUARIO-344 at 9/19/12 2:43 AM:
---------------------------------------------------------------

Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored. I don't see any in the logs.



I further debugged the application, and narrowed it down to this stack-trace:
Thread [main] (Suspended)	
	Reference.calculateDigest(boolean) line: 708	
	Reference.generateDigestValue() line: 396	
	SignedInfo(Manifest).generateDigestValues() line: 206	
	XMLSignature.sign(Key) line: 594	
	SignerEPES(SignerBES).sign(SignedDataObjects, Node, XadesSigner$SignatureAppendingStrategy) line: 259	
	SignerEPES(SignerBES).sign(SignedDataObjects, Node) line: 122	
	XmlSigning.createDetachedSignature(String, String) line: 76	

Where the line 705 in 'Reference' opens the file-handle, which is not always closed. This is line 705 (just to be sure we are seeing the same code): XMLSignatureInput output = this.dereferenceURIandPerformTransforms(os);
                
      was (Author: burnyguru):
    Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored. I don't see any in the logs.



I further debugged the application, and narrowed it down to this stack-trace:
Thread [main] (Suspended)	
	Reference.calculateDigest(boolean) line: 708	
	Reference.generateDigestValue() line: 396	
	SignedInfo(Manifest).generateDigestValues() line: 206	
	XMLSignature.sign(Key) line: 594	
	SignerEPES(SignerBES).sign(SignedDataObjects, Node, XadesSigner$SignatureAppendingStrategy) line: 259	
	SignerEPES(SignerBES).sign(SignedDataObjects, Node) line: 122	
	XmlSigning.createDetachedSignature(String, String) line: 76	

Where the line 705 opens the file-handle, which is not always closed. This is line 705 (just to be sure we are seeing the same code): XMLSignatureInput output = this.dereferenceURIandPerformTransforms(os);
                  
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Colm O hEigeartaigh updated SANTUARIO-344:
------------------------------------------

    Fix Version/s: Java 1.5.3
    
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.3
>
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458503#comment-13458503 ] 

Colm O hEigeartaigh commented on SANTUARIO-344:
-----------------------------------------------


1.5.3-SNAPSHOT is deployed here:

https://repository.apache.org/content/groups/snapshots/org/apache/santuario/xmlsec/1.5.3-SNAPSHOT/

Maybe check to see if convertToNodes is called instead in XMLSignatureInput?

Colm.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Closed] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Colm O hEigeartaigh closed SANTUARIO-344.
-----------------------------------------

    
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.3
>
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457875#comment-13457875 ] 

Andreas B. edited comment on SANTUARIO-344 at 9/19/12 2:05 AM:
---------------------------------------------------------------

Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored. I don't see any in the logs.
                
      was (Author: burnyguru):
    Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored, because I don't see any in the logs.
                  
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456978#comment-13456978 ] 

Colm O hEigeartaigh commented on SANTUARIO-344:
-----------------------------------------------


Could you post an example to reproduce the problem? I can't reproduce it. The file is read in via a FileInputStream object, but this is closed in XMLSignatureInput.getBytesFromInputStream(). Maybe garbage collection hasn't kicked in before you are trying to delete the file?

Colm.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457875#comment-13457875 ] 

Andreas B. edited comment on SANTUARIO-344 at 9/19/12 2:42 AM:
---------------------------------------------------------------

Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored. I don't see any in the logs.



I further debugged the application, and narrowed it down to this stack-trace:
Thread [main] (Suspended)	
	Reference.calculateDigest(boolean) line: 708	
	Reference.generateDigestValue() line: 396	
	SignedInfo(Manifest).generateDigestValues() line: 206	
	XMLSignature.sign(Key) line: 594	
	SignerEPES(SignerBES).sign(SignedDataObjects, Node, XadesSigner$SignatureAppendingStrategy) line: 259	
	SignerEPES(SignerBES).sign(SignedDataObjects, Node) line: 122	
	XmlSigning.createDetachedSignature(String, String) line: 76	

Where the line 705 opens the file-handle, which is not always closed. This is line 705 (just to be sure we are seeing the same code): XMLSignatureInput output = this.dereferenceURIandPerformTransforms(os);
                
      was (Author: burnyguru):
    Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored. I don't see any in the logs.
                  
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457916#comment-13457916 ] 

Colm O hEigeartaigh commented on SANTUARIO-344:
-----------------------------------------------


Could you put a breakpoint in XMLSignatureInput.getBytesFromInputStream() and see if an exception is being thrown (possibly in JavaUtils.getBytesFromStream) before inputOctetStreamProxy.close(); is called?

I've committed some code to close the internal InputStream of XMLSignatureInput on an exception - possibly this will help.

Colm.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459676#comment-13459676 ] 

Colm O hEigeartaigh commented on SANTUARIO-344:
-----------------------------------------------


I'm planning to call a vote early next week.

Colm.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.3
>
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457875#comment-13457875 ] 

Andreas B. commented on SANTUARIO-344:
--------------------------------------

Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, though it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored, because I don't see any in the logs.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459443#comment-13459443 ] 

Andreas B. commented on SANTUARIO-344:
--------------------------------------

1.5.3-SNAPSHOT does not solve it. The breakpoint in XMLSignatureInput.convertToNodes() is not reached.
When you take a look at Reference.calculateDigest(), I think you have to close the input-stream there, e.g. output.getOctetStream().close(), this closes the stream and solves my bug.
The variable name "output" is some kind of misleading, because it suggests an outputstream, but is in fact the outcome of the transformation of the inputstream (which in my case is the inputstream itself).

HTH, Andy.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457875#comment-13457875 ] 

Andreas B. edited comment on SANTUARIO-344 at 9/19/12 2:03 AM:
---------------------------------------------------------------

Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, therefore it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored, because I don't see any in the logs.
                
      was (Author: burnyguru):
    Unfortunately I can't :-(
I'm using the framework in a corporate setup with spring-batch and Xades4J, though it isn't even easy to create a simplified example I could post.
I had the same problem on a colleague's machine, although it is not a permanent problem.

To your comments:
* gc should not have any effects, because the resources are freed as soon you call .close()
* when I take a look at the source-code, .close() probably is not called, when an exception is thrown in the lines above (XMLSignatureInput.getBytesFromInputStream()). Although this could only apply to my problem, if an exception is caught somewhere, and ignored, because I don't see any in the logs.
                  
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459476#comment-13459476 ] 

Colm O hEigeartaigh commented on SANTUARIO-344:
-----------------------------------------------


Ok I have merged a fix to explicitly close the stream in Reference.calculcateDigest. The reason you were not hitting the breakpoints is that you are not using any Transforms in the Signature. For the normal use-case of one or more transforms, the FileInputStream gets closed in XMLSignatureInput.getBytes. If you could confirm with the latest 1.5.3-SNAPSHOT that'd be great.

Colm.
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.3
>
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SANTUARIO-344) XMLSignature keeps file-handle on xml-file

Posted by "Andreas B. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANTUARIO-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458482#comment-13458482 ] 

Andreas B. commented on SANTUARIO-344:
--------------------------------------

I've set a breakpoint in XMLSignatureInput.getBytesFromInputStream(), but it does not stop there!
Also, I can't find the 1.5.3-SNAPSHOT in the download archive - when should the build be available?
                
> XMLSignature keeps file-handle on xml-file
> ------------------------------------------
>
>                 Key: SANTUARIO-344
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-344
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.1
>         Environment: Windows (XP, 7)
>            Reporter: Andreas B.
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>
> When creating a signature based on a XML file (i.e. calling the method {{org.apache.xml.security.signature.XMLSignature.sign(Key signingKey)}}) the filehandle to the signed resource (the XML file) stays open after the method has finished (successfully).
> I was able to track it down to the above mentioned method, but then get lost somewhere at {{org.apache.xml.security.signature.Reference}}, which seems to use a cache for resource.
> Background: I want to delete the source-file after signature generation, which is not possible until the VM stops.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira