Skip to content

Fix SaveXmlInStreamAsync disposing stream prematurely#1680

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/implement-xssfworkbook-writeasync-again
Draft

Fix SaveXmlInStreamAsync disposing stream prematurely#1680
Copilot wants to merge 7 commits intomasterfrom
copilot/implement-xssfworkbook-writeasync-again

Conversation

Copy link

Copilot AI commented Feb 3, 2026

SaveXmlInStreamAsync used a using statement that disposed the XmlWriter, closing the underlying ZipOutputStream before all entries were written. Reading back resulted in "root element missing" exceptions.

Changes

  • StreamHelper.SaveXmlInStreamAsync: Removed using statement, manually flush without disposal
  • StreamHelper.SaveXmlInStream: Added CloseOutput = false for consistency
  • Both methods now match behavior: flush writer but leave stream open for caller
// Before: disposed writer, closed stream
using (XmlWriter writer = XmlTextWriter.Create(outStream, settings)) {
    xmlContent.WriteContentTo(writer);
    await writer.FlushAsync();
}

// After: flush only, stream stays open
settings.CloseOutput = false;
XmlWriter writer = XmlTextWriter.Create(outStream, settings);
xmlContent.WriteContentTo(writer);
await writer.FlushAsync();

Async now matches sync pattern - caller owns stream lifecycle.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 3, 2026 15:58
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
…peManager bug

Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement XSSFWorkbook.WriteAsync method with true async support Implement XSSFWorkbook.WriteAsync with true async I/O Feb 3, 2026
Copilot AI requested a review from tonyqus February 3, 2026 16:07
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title Implement XSSFWorkbook.WriteAsync with true async I/O Implement SaveAsync for MemoryPackagePart and PackagePropertiesPart Feb 3, 2026
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot AI changed the title Implement SaveAsync for MemoryPackagePart and PackagePropertiesPart Fix SaveXmlInStreamAsync disposing stream prematurely Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments