unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.54k stars 250 forks source link

[BUG] pdfWriter.Write() should return err != nil on errors to io.Writer #316

Closed ahawtho closed 4 years ago

ahawtho commented 4 years ago

Description

PdfWriter.Write() writes to an io.Writer, but never checks the return value of any of the calls to its internal bufio.Write*() calls.

Expected Behavior

I have a test that intends to verify that failed writes can be retried when writing to certain media that may fail (network write). I was surprised when my test failed. After debugging, the reason it failed was because the PdfWriter.Write() method wasn't actually returning a failure although the test was returning errors from the mock io.Writer.Write() method.

Actual Behavior

  1. Invoke PdfWriter.Write() with a Writer that returns an error
  2. Receive a nil error response.

Attachments

Include a self-contained reproducible code snippet and PDF file that demonstrates the issue.

unipdf-bug.zip

github-actions[bot] commented 4 years ago

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

gunnsth commented 4 years ago

@ahawtho Thanks for reporting. A PR has been created to address this: https://github.com/unidoc/unipdf/pull/320 Will be reviewed, then merged into development and then become released early next week.