Replace null checks on AWS SDK v2 auto-construct collections with hasX()
Apache 2.0Runs after software.amazon.awssdk.v2migration.AwsSdkJavaV1ToV2. v1 model getters returned null for a list or map the service did not send, while v2 returns an empty auto-construct collection. A migrated result.getLastEvaluatedKey() == null therefore never becomes true in v2, which can turn a pagination loop into an infinite one. This rewrites x.m() == null to !x.hasM() and x.m() != null to x.hasM() on v2 model types, and stores x.hasM() ? x.m() : null where the getter's value is kept in a variable that is later compared to null.
org. openrewrite. aws. sdk. FixAutoConstructNullChecksmod run . --recipe= org. openrewrite. aws. sdk. FixAutoConstructNullChecksInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.