Project

Profile

Help

Bug #3275

closed

On .NET, included and imported stylesheet modules get locked

Added by Michael Kay almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
-
Start date:
2017-06-13
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7
Fixed in Maintenance Release:
Platforms:

Description

According to this StackOverflow post

https://stackoverflow.com/questions/44525121/how-do-i-stop-stylesheet-file-locking-when-using-saxon

included and imported stylesheet modules are not getting closed properly after reading, and therefore remain locked.

Actions #1

Updated by Michael Kay almost 7 years ago

This has always been a tricky one because it's difficult to apply the standard policy "Whoever creates a Stream is responsible for closing it". In this case Saxon is going to call the DotNetURIResolver, which in return is going to call the .NET XmlResolver; the XmlResolver is likely to return a (.NET) Stream representing the content of the stylesheet module, which we will wrap in a DotNetInputStream, and then in a JAXP StreamSource. The UseWhenFilter then calls StylesheetModule.loadStylesheetModule(source) which isn't going to close the stream unless the source is an AugmentedSource with the "pleaseCloseAfterUse" property set.

Basically, when a stream is created by a URIResolver, there is no way the URIResolver can close the stream after use. In the StandardURIResolver we therefore avoid creating a stream (it returns a SAXSource whose InputSource contains the URI, which we leave the XML parser to dereference). But the DotNetURIResolver calls the XmlResolver, which returns a System.IO.Stream.

I suspect that in DotNetURIResolver.dereference(), where the code currently does

           if (obj instanceof Stream) {
                StreamSource source = new StreamSource(new DotNetInputStream((Stream) obj));
                source.setSystemId(abs.toString());
                return source;

we should be doing something like

           if (obj instanceof Stream) {
                StreamSource source = new StreamSource(new DotNetInputStream((Stream) obj));
                source.setSystemId(abs.toString());
                AugmentedSource as = new AugmentedSource(source);
                as.setPleaseCloseAfterUse(true);
                return as;

because no-one else is going to close the stream if we don't.

Actions #2

Updated by O'Neil Delpratt almost 7 years ago

  • Status changed from New to In Progress
  • Priority changed from Low to Normal
  • Applies to branch 9.7 added

This problem seems to be specific to Saxon-HE 9.7. The imported stylesheet file closes properly under Saxon-HE 9.8. Investigating the cause of this now.

Actions #3

Updated by O'Neil Delpratt almost 7 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100
  • Fix Committed on Branch 9.7 added

Bug fixed and committed to subversion.

In the class @XSLGeneralIncorporate@, we seem to be reading the imported stylesheet file again after we have built the tree model. The only reason for doing this seems to be a check for document fragments and for recursion. In the 9.8 branch, this logic has been dropped, but maybe we should be doing these checks when we first read the imported stylesheet in the @UseWhenFilter@.

Actions #4

Updated by O'Neil Delpratt almost 7 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.7.0.19 added

Bug fix applied in the 9.7.0.19 maintenance release.

Please register to edit this issue

Also available in: Atom PDF