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

Adapt DuplicateKeyException on insertSessionAttributes to new SQL Exception Translator #2108

Closed
marcusdacoregio opened this issue Jul 8, 2022 · 1 comment
Assignees
Labels
in: jdbc type: enhancement A general enhancement
Milestone

Comments

@marcusdacoregio
Copy link
Contributor

marcusdacoregio commented Jul 8, 2022

The commit spring-projects/spring-framework@083113d changed the way that exceptions are translated from the database exception. In some of our tests, what before was a DuplicateKeyException now is a DataIntegrityViolationException and we ignore the DataIntegrityViolationException. See:

try {
this.jdbcOperations.update(this.createSessionAttributeQuery, (ps) -> {
String attributeName = attributeNames.get(0);
ps.setString(1, session.primaryKey);
ps.setString(2, attributeName);
lobCreator.setBlobAsBytes(ps, 3, serialize(session.getAttribute(attributeName)));
});
}
catch (DuplicateKeyException ex) {
throw ex;
}
catch (DataIntegrityViolationException ex) {
// parent record not found - we are ignoring this error because we
// assume that a concurrent request has removed the session
}

The code should be adapted to the new behavior. It is important to note that in case of a duplicate key we should still consider throwing an exception since it is a clue to users that they need to expose a SessionRepositoryCustomizer Bean (see #1213)

@marcusdacoregio marcusdacoregio added type: enhancement A general enhancement type: breaks-passivity This issue breaks passivity in: jdbc labels Jul 8, 2022
@marcusdacoregio marcusdacoregio added this to the 3.0.0-M3 milestone Jul 8, 2022
@marcusdacoregio marcusdacoregio self-assigned this Jul 8, 2022
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 11, 2022
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 18, 2022
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 18, 2022
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 18, 2022
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 20, 2022
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 20, 2022
@marcusdacoregio marcusdacoregio removed the type: breaks-passivity This issue breaks passivity label Jul 20, 2022
@marcusdacoregio
Copy link
Contributor Author

Closed via #2113

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

No branches or pull requests

1 participant