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

com.maxifier.mxcache.impl.resource.ResourceOccupied Maven / Gradle / Ivy

Go to download

Constains all classes necessary for launching a MxCache-instrumentated application

There is a newer version: 2.6.9
Show newest version
/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.impl.resource;

import com.maxifier.mxcache.resource.MxResource;

import javax.annotation.Nonnull;

/**
 * ResourceOccupied.
 *
 * Please don't catch this Error. It is a part of dependency tracking and deadlock prevention of MxCache.
 *
 * It doesn't fill the stack trace!!!
 *
 * @author Alexander Kochurov ([email protected])
 */
public class ResourceOccupied extends Error {
    private final MxResource resource;

    public ResourceOccupied(@Nonnull MxResource resource) {
        this.resource = resource;
    }

    public MxResource getResource() {
        return resource;
    }

    @Override
    public Throwable fillInStackTrace() {
        // do nothing - we only need to traverse stack, not stacktrace.
        return this;
    }

    @Override
    public String getMessage() {
        return "Resource \"" + resource + "\" is locked for write. Stack will be unrolled and topmost cached method will wait for resource to be released. This exception should not be caught";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy