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

Fix JdbcUserCredentialRepository Save #16621

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

franticticktick
Copy link
Contributor

Closes gh-16620

Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

Hi, @franticticktick, I've left some feedback inline.

@@ -133,6 +152,21 @@ public void delete(Bytes credentialId) {
@Override
public void save(CredentialRecord record) {
Assert.notNull(record, "record cannot be null");
boolean existsRecord = null != this.findByCredentialId(record.getCredentialId());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the following logic achieves the same outcome:

int rows = updateCredentialRecord(record); // change to return the number of rows affected
if (rows == 0) {
    insertCredentialRecord(record);
}

This would complete more quickly and also be less load on the database.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good solution. I think we can do this polish in other places with similar logic.

@jzheaux jzheaux added in: web An issue in web modules (web, webmvc) and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 24, 2025
@jzheaux jzheaux self-assigned this Feb 24, 2025
@jzheaux
Copy link
Contributor

jzheaux commented Feb 24, 2025

Also, will you please rebase to 6.4.x since that is where the bug first appears?

@jzheaux jzheaux added the type: bug A general bug label Feb 24, 2025
@jzheaux jzheaux added this to the 6.4.x milestone Feb 24, 2025
@franticticktick
Copy link
Contributor Author

franticticktick commented Feb 25, 2025

Hi @jzheaux . Thanks for your feedback. This component was introduced in current version, so it is not in 6.4.x branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: Duplicate Primary Key Exception in Webauthn4J Authentication
3 participants