Skip to content

Remove PersistentEntity from MappingContext upon mapping metadata initialization errors #2367

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

Closed
wants to merge 2 commits into from

Conversation

gregturn
Copy link
Contributor

@gregturn gregturn commented May 3, 2021

No description provided.

gregturn added 2 commits May 3, 2021 07:58
When an error happens inside the AbstractMappingContext, the caching sometimes gets corrupted. That's because some exceptions are caught, others are not. Instead, the error handling that clears out the cache needs to be shifted up one level, resulting in a simpler code block.

See #2329.
@gregturn gregturn changed the title - [X] You have read the [Spring Data contribution guidelines](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc). - [X] You use the code formatters provided [here](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide) and have them applied to your changes. Don’t submit any formatting related changes. - [X] You submit test cases (unit or integration tests) that back your changes. - [X] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only). Shift error handling up one level May 3, 2021
@gregturn
Copy link
Contributor Author

gregturn commented May 3, 2021

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@gregturn gregturn requested a review from mp911de May 3, 2021 13:04
}

} catch (BeansException e) {
throw new MappingException(e.getMessage(), e);
} catch (RuntimeException e) {
Copy link
Member

Choose a reason for hiding this comment

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

We should also remove the entity from the cache upon BeansException

@mp911de mp911de self-assigned this Jul 13, 2021
mp911de pushed a commit that referenced this pull request Jul 20, 2021
…tialization errors.

When an error happens inside the AbstractMappingContext, the caching sometimes gets corrupted. That's because some exceptions are caught, others are not. Instead, the error handling that clears out the cache needs to be shifted up one level, resulting in a simpler code block.

Closes #2329
Original pull request: #2367.
mp911de added a commit that referenced this pull request Jul 20, 2021
Extract adding the actual entity to the MappingContext into its own method along with error handling spanning the entire entity initialization process.

See #2329
Original pull request: #2367.
mp911de pushed a commit that referenced this pull request Jul 20, 2021
…tialization errors.

When an error happens inside the AbstractMappingContext, the caching sometimes gets corrupted. That's because some exceptions are caught, others are not. Instead, the error handling that clears out the cache needs to be shifted up one level, resulting in a simpler code block.

Closes #2329
Original pull request: #2367.
mp911de added a commit that referenced this pull request Jul 20, 2021
Extract adding the actual entity to the MappingContext into its own method along with error handling spanning the entire entity initialization process.

See #2329
Original pull request: #2367.
@mp911de mp911de changed the title Shift error handling up one level Remove PersistentEntity from upon mapping metadata initialization errors. Jul 20, 2021
@mp911de mp911de changed the title Remove PersistentEntity from upon mapping metadata initialization errors. Remove PersistentEntity from MappingContext upon mapping metadata initialization errors Jul 20, 2021
@mp911de mp911de added the type: bug A general bug label Jul 20, 2021
@mp911de mp911de added this to the 2.5.4 (2021.0.4) milestone Jul 20, 2021
@mp911de
Copy link
Member

mp911de commented Jul 20, 2021

That's merged, polished, and backported now.

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

Successfully merging this pull request may close these issues.

Partially populated PersistentEntity instances not properly removed from cache (1st nesting level edge case)
2 participants