Skip to content

Commit 703ce02

Browse files
committed
Release 5.17.1
1 parent 09613ee commit 703ce02

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Release Notes
22
====
33

4+
# 12-30-2024
5+
<a href="https://www.nuget.org/packages/dotnext.io/5.17.1">DotNext.IO 5.17.1</a>
6+
* Fixed `EndOfStreamException` caused by async read from `PoolingBufferedStream`
7+
48
# 12-29-2024
59
This release is aimed to improve AOT compatibility. All the examples in the repo are now AOT compatible.
610
<a href="https://www.nuget.org/packages/dotnext/5.17.0">DotNext 5.17.0</a>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This release is aimed to improve AOT compatibility. All the examples in the repo
6666
<a href="https://www.nuget.org/packages/dotnext.threading/5.17.0">DotNext.Threading 5.17.0</a>
6767
* Improved AOT support
6868

69-
<a href="https://www.nuget.org/packages/dotnext.io/5.17.0">DotNext.IO 5.17.0</a>
69+
<a href="https://www.nuget.org/packages/dotnext.io/5.17.1">DotNext.IO 5.17.1</a>
7070
* Reduced memory consumption for applications that use `FileReader` and `FileWriter` classes. These classes are now implemented by using lazy buffer pattern. It means that the different instances can reuse the same buffer taken from the pool
7171
* Fixed [255](https://github.com/dotnet/dotNext/issues/255)
7272
* `PoolingBufferedStream` is introduced to replace classic [BufferedStream](https://learn.microsoft.com/en-us/dotnet/api/system.io.bufferedstream). This class supports memory pooling and implements lazy buffer pattern

src/DotNext.IO/DotNext.IO.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Authors>.NET Foundation and Contributors</Authors>
1212
<Company />
1313
<Product>.NEXT Family of Libraries</Product>
14-
<VersionPrefix>5.17.0</VersionPrefix>
14+
<VersionPrefix>5.17.1</VersionPrefix>
1515
<VersionSuffix></VersionSuffix>
1616
<AssemblyName>DotNext.IO</AssemblyName>
1717
<PackageLicenseExpression>MIT</PackageLicenseExpression>

src/DotNext.IO/IO/PoolingBufferedStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public override ValueTask<int> ReadAsync(Memory<byte> data, CancellationToken to
477477
{
478478
task = ValueTask.FromException<int>(new NotSupportedException());
479479
}
480-
else if (buffer.IsEmpty)
480+
else if (data.IsEmpty)
481481
{
482482
task = new(result: 0);
483483
}

src/DotNext.Tests/IO/PoolingBufferedStreamTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,36 @@ public static void ResetBuffer()
341341
bufferedStream.Reset();
342342
False(bufferedStream.HasBufferedDataToWrite);
343343
}
344+
345+
[Fact]
346+
public static void ReadFromFile()
347+
{
348+
var expected = RandomBytes(4096);
349+
using var handle = File.OpenHandle(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()), FileMode.CreateNew, FileAccess.ReadWrite,
350+
options: FileOptions.DeleteOnClose);
351+
RandomAccess.Write(handle, expected, fileOffset: 0L);
352+
RandomAccess.FlushToDisk(handle);
353+
354+
using var bufferedStream = new PoolingBufferedStream(handle.AsUnbufferedStream(FileAccess.Read)) { MaxBufferSize = 128 };
355+
var actual = new byte[expected.Length];
356+
bufferedStream.ReadExactly(actual);
357+
358+
Equal(expected, actual);
359+
}
360+
361+
[Fact]
362+
public static async Task ReadFromFileAsync()
363+
{
364+
var expected = RandomBytes(4096);
365+
using var handle = File.OpenHandle(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()), FileMode.CreateNew, FileAccess.ReadWrite,
366+
options: FileOptions.DeleteOnClose | FileOptions.Asynchronous);
367+
await RandomAccess.WriteAsync(handle, expected, fileOffset: 0L);
368+
RandomAccess.FlushToDisk(handle);
369+
370+
await using var bufferedStream = new PoolingBufferedStream(handle.AsUnbufferedStream(FileAccess.Read)) { MaxBufferSize = 128 };
371+
var actual = new byte[expected.Length];
372+
await bufferedStream.ReadExactlyAsync(actual);
373+
374+
Equal(expected, actual);
375+
}
344376
}

src/examples/HyParViewPeer/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ static Task PrintNeighborsAsync(HttpContext context)
132132

133133
file sealed class RumorSender : Disposable, IRumorSender
134134
{
135-
internal const string SenderAddressHeader = "X-Sender-Address";
136-
internal const string SenderIdHeader = "X-Rumor-ID";
135+
private const string SenderAddressHeader = "X-Sender-Address";
136+
private const string SenderIdHeader = "X-Rumor-ID";
137137

138138
internal const string RumorResource = "/rumor";
139139
internal const string BroadcastResource = "/broadcast";

0 commit comments

Comments
 (0)