-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workaround for duplicate session key exception
Russell keeps hitting this first thing in the morning. Hopefully this will help.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package pandas.core; | ||
|
||
import org.springframework.context.annotation.*; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.session.jdbc.OracleJdbcIndexedSessionRepositoryCustomizer; | ||
|
||
@Configuration | ||
public class SessionConfig { | ||
// This is a workaround for an exception we get seemingly randomly hit occasionally when sessions | ||
// are first created and the session insert fails with duplicate key exception. | ||
// Seems to be a relatively common issue with Spring Session: https://stackoverflow.com/a/69540376 | ||
@Bean | ||
@Conditional(OracleDatabaseCondition.class) | ||
public OracleJdbcIndexedSessionRepositoryCustomizer oracleJdbcIndexedSessionRepositoryCustomizer() { | ||
return new OracleJdbcIndexedSessionRepositoryCustomizer(); | ||
} | ||
|
||
public static class OracleDatabaseCondition implements Condition { | ||
@Override | ||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
String jdbcUrl = context.getEnvironment().getProperty("spring.datasource.url"); | ||
return jdbcUrl != null && jdbcUrl.startsWith("jdbc:oracle:"); | ||
} | ||
} | ||
} |