Skip to content

Remove dead code in parseArrayDynamic#108912

Closed
kkrik-es wants to merge 3 commits intoelastic:mainfrom
kkrik-es:fix/synthetic-source/dead-code
Closed

Remove dead code in parseArrayDynamic#108912
kkrik-es wants to merge 3 commits intoelastic:mainfrom
kkrik-es:fix/synthetic-source/dead-code

Conversation

@kkrik-es
Copy link
Copy Markdown
Member

Noticed that the code never executed while running tests for #108911


private static void parseArrayDynamic(DocumentParserContext context, String currentFieldName) throws IOException {
ensureNotStrict(context, currentFieldName);
if (context.dynamic() == ObjectMapper.Dynamic.FALSE) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the removed part, the rest is just shifted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I run the DynamicMappingTests#testArraysDynamicFalse() test then the if statement does seem to be executed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The test still passes though, I wonder if it has any effect in practice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So what happens is that the function calls #parseDynamicValue that also checks for this, returning immediately.

We can remove it to simplify the logic, but it's fine to keep it too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the test doesn't validate that skipChildren() is invoked, which I think is the point of the whole if statement (avoid parsing stuff that we're not going to use). Not sure how, but I think the test should somehow assert that skipChildren() is invoked.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is actually needed, I added more tests.. lemme revert for now.

@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine update branch

1 similar comment
@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine update branch

@kkrik-es
Copy link
Copy Markdown
Member Author

run elasticsearch-ci/bwc-snapshots

@kkrik-es
Copy link
Copy Markdown
Member Author

run elasticsearch-ci/8.13.5 / bwc-snapshots

@kkrik-es kkrik-es marked this pull request as ready for review May 23, 2024 12:54
@kkrik-es kkrik-es requested a review from martijnvg May 23, 2024 12:54
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@kkrik-es kkrik-es closed this May 23, 2024
@kkrik-es kkrik-es deleted the fix/synthetic-source/dead-code branch May 23, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants