Skip to content

Commit

Permalink
Fixed null reference exception in ReGrid.OpenDownloadStreamAsync()
Browse files Browse the repository at this point in the history
  • Loading branch information
bchavez committed Feb 18, 2016
1 parent a523a7c commit 7112ec9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## v2.2.8-beta-31
## v2.2.8-beta-3
* Promoted anonymous types to expressions. R.Expr(new {keya="vala"}).Keys()
* Fixed null reference exception in ReGrid.OpenDownloadStreamAsync()

## v2.2.8-beta-2
* Issue 32: Adding back `dnx451`, `dnxcore50`.
Expand Down
14 changes: 9 additions & 5 deletions Source/RethinkDb.Driver.ReGrid.Tests/DownloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ public async Task test_async_method()
{
CreateBucketWithOneFileTwoChunks();

var opts = new DownloadOptions();
using( var cts = new CancellationTokenSource() )
{

var fs = await bucket.OpenDownloadStreamAsync(testfile, opts).ConfigureAwait(false);
var opts = new DownloadOptions();

using( fs )
{
fs.Should().NotBeNull();
var fs = await bucket.OpenDownloadStreamAsync(testfile, cts.Token).ConfigureAwait(false);

using( fs )
{
fs.Should().NotBeNull();
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions Source/RethinkDb.Driver.ReGrid/Bucket.Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ public Task DownloadToStreamByNameAsync(string filename, Stream destination, Can
/// <param name="options"><see cref="DownloadOptions"/></param>
public DownloadStream OpenDownloadStream(string filename, int revision = -1, DownloadOptions options = null)
{
options = options ?? new DownloadOptions();
return OpenDownloadStreamAsync(filename, options, revision).WaitSync();
}

Expand All @@ -189,9 +188,11 @@ public DownloadStream OpenDownloadStream(string filename, int revision = -1, Dow
/// <param name="revision">-1: The most recent revision. -2: The second most recent revision. -3: The third most recent revision. 0: The original stored file. 1: The first revision. 2: The second revision. etc...</param>
/// <param name="options"><see cref="DownloadOptions"/></param>
/// <param name="cancelToken"><see cref="CancellationToken"/></param>
public async Task<DownloadStream> OpenDownloadStreamAsync(string filename, DownloadOptions options, int revision = -1,
public async Task<DownloadStream> OpenDownloadStreamAsync(string filename, DownloadOptions options = null, int revision = -1,
CancellationToken cancelToken = default(CancellationToken))
{
options = options ?? new DownloadOptions();

var fileInfo = await this.GetFileInfoByNameAsync(filename, revision, cancelToken)
.ConfigureAwait(false);

Expand Down

0 comments on commit 7112ec9

Please sign in to comment.