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

io.github.spitmaster.warlock.handler.FastFailTimeoutHandler Maven / Gradle / Ivy

Go to download

warlock-spring-boot-starter is an annotation-driven concurrency tools library for java with Spring. It is easy to use in Spring application Just using annotation on your method , the concurrency lock problem would be solved

There is a newer version: 1.0.1
Show newest version
package io.github.spitmaster.warlock.handler;

import io.github.spitmaster.warlock.exceptions.WarlockException;
import org.aopalliance.intercept.MethodInvocation;

/**
 * 超时抛出异常
 * 等待超时: 抛出异常, 方法不执行
 * 执行超时: 抛出异常, 方法虽然执行完毕, 但丢弃返回值
 *
 * @author zhouyijin
 */
public enum FastFailTimeoutHandler implements WaitTimeoutHandler, LeaseTimeoutHandler {
    //单例
    INSTANCE;

    @Override
    public Object handleWaitTimeout(MethodInvocation methodInvocation) throws Throwable {
        throw new WarlockException("wait timeout; timeout from " + methodInvocation.getMethod().getName());
    }

    @Override
    public Object handleLeaseTimeout(MethodInvocation methodInvocation, Object result) throws Throwable {
        throw new WarlockException("lease timeout; timeout from " + methodInvocation.getMethod().getName());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy