-
Notifications
You must be signed in to change notification settings - Fork 856
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
fix: Delay the cast from IAmazonDynamoDB to AmazonDynamoDBClient in the DocumentModel #3388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor nits but change looks good.
var serviceResponse = client.BatchGetItem(request); | ||
#if AWS_ASYNC_API | ||
// Cast the IAmazonDynamoDB to the concrete client instead, so we can access the internal sync-over-async methods | ||
var internalClient = client as AmazonDynamoDBClient; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: You can move the casting logic outside of the loop and only do it once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aa1e327
{ | ||
do | ||
{ | ||
var result = client.BatchWriteItem(request); | ||
#if AWS_ASYNC_API | ||
// Cast the IAmazonDynamoDB to the concrete client instead, so we can access the internal sync-over-async methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Move the casting logic above the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aa1e327
Realized that I was using too wide of a condition This also made some .NET Framework tests invalid, so I removed them. |
…mazon.DynamoDBv2.DocumentModel to only when it's necessary for sync-over-async code paths. This allows mocking for async callers.
c8176aa
to
9fa85ad
Compare
Dry-run e8acaff2-7604-4ade-a913-8ea4cc934cfe passed after adding 2f8a80e |
Description
Before: When initializing the document model
Table
object with anIAmazonDynamoDB
, .NET/Standard/Core, we cast it right away to anAmazonDynamoDBClient
.Table
APIs, which still rely on the internal sync low-level APIs internally.internal
onAmazonDynamoDBClient
. This is why we need the cast, since the sync low-level APIs are no longer part of the publicIAmazonDynamoDB
.Now: We delay the cast until right before we need to access the internal, low-level sync APIs.
AmazonDynamoDBClient
, you'll now see a clearerInvalidOperationException
instead of theNullReferenceException
from the failed cast.Future:
Table
sync-over-async APIs entirely. This would remove the need for this cast.Motivation and Context
DOTNET-6755 and #1589 (most of the way, until we do on of the Future ideas from above)
This allows
Table
consumers to mock theIAmazonDynamoDB
from .NET/Standard/Core as long as you stick to async public APIs.Testing
PENDING - .NET Standard integ tests for DDB
Types of changes
Checklist
License