aws-doc-sdk-examples icon indicating copy to clipboard operation
aws-doc-sdk-examples copied to clipboard

[Bug]: The example code for EnhancedGetItem can result in null pointer exception

Open CaptainDaVinci opened this issue 2 years ago • 0 comments

Expected behavior

The example code in javav2/example_code/dynamodb/src/main/java/com/example/dynamodb/enhanced/EnhancedGetItem.java

can result in an NPE if the key is not found in the dynamodb table.

Actual behavior

Handle the case where key might be missing from dynamodb table and table.getItem returns null

Steps to reproduce

Run the example code in javav2/example_code/dynamodb/src/main/java/com/example/dynamodb/enhanced/EnhancedGetItem.java and pass a key that is missing from the table.

Logs / stacktrace (if applicable)

No response

Which SDK were you using?

Java (v2)

Which OS were you using?

macOS

SDK version

2.20.162

OS version

13.5.2

CaptainDaVinci avatar Nov 10 '23 07:11 CaptainDaVinci