All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kenshoo.pl.entity.mysql.MySqlDeadlockDetector Maven / Gradle / Ivy

Go to download

A Java persistence layer based on JOOQ for high performance and business flow support.

There is a newer version: 0.1.121-jooq-3.16.3
Show newest version
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