-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete data returned from StreamByteBuffer #1313
Comments
Thats a very good point, Thanks for showing up this issue and also for presenting the solution. Do you want to make a PR for that? |
Sure, I'll get one up. |
When should I expect this fix to be released? Looking forward to pulling the changes. |
usually there is a release every few months. |
Thanks, @gofal - we currently consume the nuget package as part of https://github.com/microsoft/dicom-server. That's the main way we prefer to consume the code for a few different reasons, but we'll look into building based on a pinned commit. I don't intend to pester the maintainers for small fixes / bugs but I thought this was a pretty important fix since it causes data to be missing in a request. We do have a workaround using |
Sure, I see. This bugfix will justify a release. I will plan to do an update until next week. |
Describe the bug
Summary: stream reading in
StreamByteBuffer
is incomplete.When a
DicomFile
is created from aStream
, by default large tags will be saved as aStreamByteBuffer
, so that the data can be retrieved on demand but not block other operations. When the bytes are requested from theStreamByteBuffer
, the Data accessor and GetByteRange both make a single call toStream.Read
. However, the underlyingStream
is not guaranteed to have all of the requested bytes available, and so what can be returned is a byte array with only part of the requested data.This came to light in the context of an Azure Storage
LazyLoadingReadOnlyStream
, which buffers 4MB by default. The returned byte array for a pixel data element > 4MB will have 4MB of data and the rest of the array will be null values.As this issue makes clear, this is expected behavior for all
Streams
, and so the consumer should check the return value of calls toStream.Read
until no more bytes are returned. The same logic is already implemented in theCopyToStream*
methods.To Reproduce
Here's a code sample that uses a toy buffered stream to simulate the buffering behavior, and gets
StreamByteBuffer.Data
with the existing logic (which results in incomplete data) versus updated logic (which results in complete data).Expected behavior
I expect
StreamByteBuffer.Data
to return the entire requested range of bytes. There should be no concerns about blocking since this is an on-demand retrieval.Environment
Fellow Oak DICOM version: (5.0.2)
OS: (Windows 10 x64)
Platform: (all)
The text was updated successfully, but these errors were encountered: