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

[Tables] Fix Deserialization Issues within ListEntities #40392

Merged
merged 27 commits into from
Jun 12, 2024

Conversation

jairmyree
Copy link
Member

@jairmyree jairmyree commented May 29, 2024

After the azure-json migration, there was a Tables bug arising where data types were not being deserialized appropriately.

This PR fixes the deserialization issues and adds additional testing to ensure that getEntity and listEntities maintain parity on expected results.

@jairmyree jairmyree requested a review from vcolin7 as a code owner May 29, 2024 19:16
@jairmyree
Copy link
Member Author

Need to add mirror tests to the asynchronous client.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@jairmyree
Copy link
Member Author

Need to add a follow-up to transition disabled tests to live-only.

@jairmyree
Copy link
Member Author

Closes #40385
Closes #39710

Copy link
Member

@joshfree joshfree left a comment

Choose a reason for hiding this comment

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

Left some comments; marking approved, assuming comments are addressed

@@ -50,7 +50,7 @@ public static TableEntity createEntity(Map<String, Object> properties) {
}
}

return creator.get().setProperties(properties);
return creator.get().setProperties(TableUtils.adjustOdataPropertyMap(properties));
Copy link
Member

Choose a reason for hiding this comment

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

L42 - should you be checking properties for null at the method start

Copy link
Member Author

Choose a reason for hiding this comment

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

@joshfree That is not necessary because adjustOdataPropertyMap makes use of computeIfPresent from Java.util.Map which will ignore null properties.

byte[] bytes = java.util.Base64.getDecoder().decode(((String) adjustedMap.get(key)).getBytes());
return bytes;
}
} else if ("Edm.DateTime".equals(odataType)) {
Copy link
Member

Choose a reason for hiding this comment

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

These string literals are in at least two places in the code now.

Can you make these protected static final and use them here and in the EntityDataModelType where they're also used?

}


@Disabled("This test is disabled because it is not supported using MI.")
Copy link
Member

Choose a reason for hiding this comment

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

Please don't disable tests that are testing legitimate scenarios. Keep them.

/cc @g2vinay @schaabs

Copy link
Member Author

Choose a reason for hiding this comment

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

@joshfree My plan was to mark them Live-Only in a follow-up PR but I can just do that now. I was having issues with merging from main earlier but my rebase went cleanly so it should be fine now.

@jairmyree jairmyree force-pushed the tables/bug/OffsetDateTime-as-String branch from 7173273 to 23e2b12 Compare May 29, 2024 23:40
@jairmyree jairmyree force-pushed the tables/bug/OffsetDateTime-as-String branch from e3c5698 to 6570051 Compare June 5, 2024 23:16
@@ -17,7 +17,7 @@
* The properties for the table entity query response.
*/
@Fluent
public final class TableEntityQueryResponse implements JsonSerializable<TableEntityQueryResponse> {
public final class TableEntityQueryResponse extends TablesJacksonSerializer implements JsonSerializable<TableEntityQueryResponse> {
Copy link
Member

Choose a reason for hiding this comment

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

From an API perspective, I think it would be better for TableEntityQueryResponseto have a constant property of aTablesJacksonSerializerrather than extending it. Every time an instance ofTableEntityQueryResponseis instantiated it will create a new instance ofJacksonAdapteras super types are initialized on creation. This will have a large overhead as this will create newObjectMapper`'s each time, which is expensive.

@@ -122,7 +122,7 @@ private static boolean shouldGetEntityFieldsAsMap(Type type) {
}

@SuppressWarnings("unchecked")
private static <U> U deserializeTableEntityQueryResponse(JsonReader jsonReader) throws IOException {
protected static <U> U deserializeTableEntityQueryResponse(JsonReader jsonReader) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

I'd just make this public, protected really doesn't get us anything.

/**
* Table service data types.
*/
public abstract class TableServiceDataTypes {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see this type being used anywhere other than in EntityDataModelType, does this class need to exist to hold these constants or can they be constants in EntityDataModelType instead?

@jairmyree jairmyree merged commit 955e1ff into Azure:main Jun 12, 2024
19 checks passed
@jairmyree jairmyree deleted the tables/bug/OffsetDateTime-as-String branch June 12, 2024 16:04
@rwmajor2
Copy link

@jairmyree Do you when this will be available in a release on maven central? I just ran into this issue also that was causing code to break.

@jairmyree
Copy link
Member Author

@rwmajor2 azure-data-tables 12.4.2 was just released today. Outside of the time it takes to propagate through maven central, it should be available immediately.

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

Successfully merging this pull request may close these issues.

5 participants