com.kenshoo.pl.entity.mysql.MySqlDeadlockDetector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of persistence-layer Show documentation
Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
package com.kenshoo.pl.entity.mysql;
import com.google.common.base.Splitter;
import com.google.common.base.Throwables;
import com.kenshoo.pl.entity.spi.DeadlockDetector;
import org.jooq.lambda.Seq;
import java.sql.SQLException;
import static org.jooq.lambda.Seq.seq;
public class MySqlDeadlockDetector implements DeadlockDetector {
private String retryPatterns = "lock wait timeout exceeded;deadlock";
@Override
public boolean isDeadlock(Throwable e) {
Throwable rootCause = Throwables.getRootCause(e);
return rootCause instanceof SQLException
&& rootCause.getMessage() != null
&& deadlockStrings().anyMatch(rootCause.getMessage().toLowerCase()::contains);
}
private Seq deadlockStrings() {
return seq(Splitter.on(";")
.trimResults()
.omitEmptyStrings()
.splitToList(retryPatterns));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy