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

Add logic to handle number acceptors #5813

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

RanVaknin
Copy link

@RanVaknin RanVaknin commented Jan 21, 2025

Motivation and Context

Currently the Java SDK waiter matcher acceptor only support Integers. According to the cross SDK spec waiter matcher acceptor must support all number types.

Modifications

  • Changed jmspathruntime numbers internally to use BigDecimal for all number types in order to support arbitrary precision.
  • Updated Jackson Jr version to 2.17.3 to support Big Decimal.

Testing

  • Added WaitersPathMatcherTest for numeric matchers
  • Added coverage to existing numeric handling tests

@RanVaknin RanVaknin changed the title add logic to handle number acceptors Add logic to handle number acceptors Jan 21, 2025
@RanVaknin RanVaknin force-pushed the rvaknin/number-support-for-waiters branch from 4fb548f to cd55716 Compare January 28, 2025 23:43
@RanVaknin RanVaknin marked this pull request as ready for review January 29, 2025 01:29
@RanVaknin RanVaknin requested a review from a team as a code owner January 29, 2025 01:29
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
50.4% Coverage on New Code (required ≥ 80%)
15.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@dagnir dagnir left a comment

Choose a reason for hiding this comment

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

Can we add tests in codegen for generated waiters that use numbers?

@@ -57,6 +57,7 @@
* this interpreter make heavy use of the {@code JmesPathRuntime}.
*/
public class JmesPathAcceptorGenerator {
private static final ClassName BIG_DECIMAL = ClassName.get("java.math", "BigDecimal");
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simplify this to ClassName.get(BigDecimal.class)

@@ -0,0 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

This feature doesn't need a changelog entry, since the changelog is for customer facing changes; this is more of an internal feature (though it does mean it will allow us to potentially offer more waiters for customers in the future).

@@ -36,7 +36,9 @@ public final class Jackson {
.disable(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.enable(JSON.Feature.PRETTY_PRINT_OUTPUT)
.enable(JSON.Feature.READ_JSON_ARRAYS_AS_JAVA_ARRAYS)
.treeCodec(new JacksonJrsTreeCodec());
.enable(JSON.Feature.USE_BIG_DECIMAL_FOR_FLOATS)
.register(new JrSimpleTreeExtension());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just add a small comment here why we're adding JrSimpleTreeExtension? It's not obvious that it's to enable the BigDecimal support.

if (value instanceof BigDecimal) {
this.numberValue = (BigDecimal) value;
} else {
this.numberValue = new BigDecimal(value.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

BigDecimal has constructors that take either long or double. Can we check for those types and use those constructors instead? It will be more efficient than converting them to a string then back to a number

if (value instanceof Double || value instanceof Float) {
    ...

@@ -375,8 +375,7 @@
"Integer":{"type":"integer"},
// Shape is customized to BigDecimal in customization.config
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove this comment

@@ -62,8 +62,7 @@ public void clientBuilder_settingRetryModeInOverrideConfigurationConsumer() {
// Configuring the client using RetryMode should support AWS retryable conditions.
ProtocolRestJsonClient client = client(b -> b.overrideConfiguration(o -> o.retryStrategy(RetryMode.STANDARD)));
assertThrows(ProtocolRestJsonException.class, () -> callAllTypes(client));
// Three requests, i.e., there were retries.
verifyRequestCount(3);
// Three requests, i.e., th
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably didn't mean to delete this line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants