Skip to content
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

Fixes the missing exception throw action when an api request is executed, like BucketExistsAsync, etc. #1141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,29 @@ internal static async Task BucketExists_Test(IMinioClient minio)
await minio.RemoveBucketAsync(rbArgs).ConfigureAwait(false);

var found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
Assert.IsFalse(found);
if (found)
throw new Exception("BucketExistsAsync api failed to return false for a non-existing bucket");

await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false);
found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
Assert.IsTrue(found);
new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExists passes",

if (!found)
throw new Exception("BucketExistsAsync api failed to return true for an existing bucket");

new MintLogger(nameof(BucketExists_Test), bucketExistsSignature,
"Tests whether BucketExistsAsync api passes",
TestStatus.PASS, DateTime.Now - startTime, args: args).Log();
}
catch (NotImplementedException ex)
{
new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExists passes",
new MintLogger(nameof(BucketExists_Test), bucketExistsSignature,
"Tests whether BucketExistsAsync api passes",
TestStatus.NA, DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log();
}
catch (Exception ex)
{
new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExists passes",
new MintLogger(nameof(BucketExists_Test), bucketExistsSignature,
"Tests whether BucketExistsAsync api passes",
TestStatus.FAIL, DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log();
throw;
}
Expand Down Expand Up @@ -586,17 +594,17 @@ internal static async Task TearDown(IMinioClient minio, string bucketName)
{
var beArgs = new BucketExistsArgs()
.WithBucket(bucketName);
var bktExists = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
if (!bktExists)
return;
var getVersions = false;
// Get Versioning/Retention Info.
var lockConfigurationArgs =
new GetObjectLockConfigurationArgs()
.WithBucket(bucketName);
ObjectLockConfiguration lockConfig = null;
var lockConfig = new ObjectLockConfiguration();
try
{
var bktExists = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
if (!bktExists)
return;
// Get Versioning/Retention Info.
var lockConfigurationArgs =
new GetObjectLockConfigurationArgs()
.WithBucket(bucketName);
var versioningConfig = await minio.GetVersioningAsync(new GetVersioningArgs()
.WithBucket(bucketName)
.WithVersions(true)).ConfigureAwait(false);
Expand Down
8 changes: 3 additions & 5 deletions Minio/RequestExtensions.cs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All code from lines 147-155 can be replaced by throw; and you would have had the same functionality as you implemented right now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
if (ex.Message.Equals("ThrowBucketNotFoundException", StringComparison.Ordinal))
throw new BucketNotFoundException();

if (responseResult is not null)
responseResult.Exception = ex;
else
responseResult = new ResponseResult(request, ex);
return responseResult;
if (responseResult is not null) responseResult.Exception = ex;
else return new ResponseResult(request, ex);
throw;
}
}

Expand Down
Loading