Skip to content

DynamoDbIgnoreNulls example assertions are incorrect #4459

Closed

Description

@tkhill-AWS

Describe the issue

The javadoc for DynamoDbIgnoreNulls shows two assertions at the end.

 // innerBean1 w/ @DynamoDbIgnoreNulls does not have any attribute values because all the fields are null
 assertThat(itemMap.get("innerBean1").m(), empty());

 // innerBean2 w/o @DynamoDbIgnoreNulls has a NULLL attribute.
 assertThat(nestedBean.getInnerBean2(), hasEntry("attribute", nullAttributeValue()));

Assuming that hamcrest matchers are being used, for example

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;

I found that assertThat(itemMap.get("innerBean1").m(), empty()); does not compile. Matchers.empty() is used to check a Collection, but itemMap.get("innerBean1").m() returns a Map. A Map is not a Collection.

Also, the second assertion:

assertThat(nestedBean.getInnerBean2(), hasEntry("attribute", nullAttributeValue()));

doesn't make since since nestedBean.getInnerBean2(), returns null and hasEntry("attribute", nullAttributeValue()) is checking for an entry in a map.

Links

https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.html

Activity

  1. added
    documentation
    needs-triage
    on Sep 21, 2023
  2. Ignacio-Trottaa commented on Dec 17, 2025

    @Ignacio-Trottaa

    Hi! I'm interested in working on this issue. This would be one of my first contributions to the project.

    I can see the Hamcrest matchers in the javadoc examples have some issues that prevent compilation. Could you please assign this to me?

    thanks

  3. bhoradc commented on Mar 11, 2026

    @bhoradc
    Contributor

    Hi @Ignacio-Trottaa, apologies for the late response. Are you still interested in contributing a fix for this? If so, feel free to submit a PR and we'll review it. Thanks!

  4. added
    p2
    and removed
    needs-triage
    on Mar 11, 2026
  5. CheHyeonYeong commented on Mar 28, 2026

    @CheHyeonYeong
    Contributor

    Hi, I'd like to work on this issue.

    I noticed the assertion examples in the Javadoc are incorrect:

    1. empty() matcher is for Collections, but itemMap.get("innerBean1").m() returns a Map
    2. nestedBean.getInnerBean2() returns null, so hasEntry() doesn't make sense here

    I'll submit a PR to fix these examples with correct assertions.

  6. github-actions commented on Apr 3, 2026

    @github-actions

    This issue is now closed. Comments on closed issues are hard for our team to see.
    If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions