Skip to content

Remove redundant code in DefaultEntityCallbacks#callback #3053

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 1 commit into from

Conversation

mawen12
Copy link
Contributor

@mawen12 mawen12 commented Feb 28, 2024

Resolves #3055

I have found org.springframework.data.mapping.callback.DefaultEntityCallbacks#callback method exists redunant code.

entity is checked not null, then don't need to call callbackDiscoverer.resolveDeclaredEntityType(callbackType).getRawClass()).

current code:

@Override
public <T> T callback(Class<? extends EntityCallback> callbackType, T entity, Object... args) {

    Assert.notNull(entity, "Entity must not be null");
    // redunant code 
    Class<T> entityType = (Class<T>) (entity != null ? ClassUtils.getUserClass(entity.getClass())
		: callbackDiscoverer.resolveDeclaredEntityType(callbackType).getRawClass());
    ......
}

after:

@Override
public <T> T callback(Class<? extends EntityCallback> callbackType, T entity, Object... args) {

    Assert.notNull(entity, "Entity must not be null");
    
    Class<T> entityType = (Class<T>) ClassUtils.getUserClass(entity.getClass());
    ......
}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 28, 2024
@mp911de mp911de changed the title fixes: remove redundant code in DefaultEntityCallbacks#callback Remove redundant code in DefaultEntityCallbacks#callback Mar 1, 2024
@mp911de mp911de added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 1, 2024
@mp911de mp911de self-assigned this Mar 1, 2024
mp911de pushed a commit that referenced this pull request Mar 1, 2024
mp911de added a commit that referenced this pull request Mar 1, 2024
Handle warnings. Remove redundant code in DefaultReactiveEntityCallbacks.

Original pull request: #3053
See #3055
mp911de pushed a commit that referenced this pull request Mar 1, 2024
mp911de added a commit that referenced this pull request Mar 1, 2024
Handle warnings. Remove redundant code in DefaultReactiveEntityCallbacks.

Original pull request: #3053
See #3055
mp911de pushed a commit that referenced this pull request Mar 1, 2024
mp911de added a commit that referenced this pull request Mar 1, 2024
Handle warnings. Remove redundant code in DefaultReactiveEntityCallbacks.

Original pull request: #3053
See #3055
@mp911de
Copy link
Member

mp911de commented Mar 1, 2024

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de closed this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redunant code in DefaultEntityCallbacks#callback
3 participants