Search in sources :

Example 1 with PersistentObject

use of com.thoughtworks.go.domain.PersistentObject in project gocd by gocd.

the class GoCache method logUnsavedPersistentObjectInteraction.

private void logUnsavedPersistentObjectInteraction(Object value, String message) {
    if (value instanceof PersistentObject) {
        for (Class<? extends PersistentObject> nullObjectClass : nullObjectClasses) {
            if (value.getClass().equals(nullObjectClass)) {
                return;
            }
        }
        PersistentObject persistentObject = (PersistentObject) value;
        if (!persistentObject.hasId()) {
            String msg = String.format(message, persistentObject);
            IllegalStateException exception = new IllegalStateException();
            LOGGER.error(msg, exception);
            throw bomb(msg, exception);
        }
    }
}
Also used : PersistentObject(com.thoughtworks.go.domain.PersistentObject)

Example 2 with PersistentObject

use of com.thoughtworks.go.domain.PersistentObject in project gocd by gocd.

the class GoCache method getWithoutTransactionCheck.

private Object getWithoutTransactionCheck(String key) {
    Element element = ehCache.get(key);
    if (element == null) {
        return null;
    }
    Object value = element.getObjectValue();
    logUnsavedPersistentObjectInteraction(value, "PersistentObject {} without an id served out of cache.");
    return value;
}
Also used : Element(net.sf.ehcache.Element) PersistentObject(com.thoughtworks.go.domain.PersistentObject)

Aggregations

PersistentObject (com.thoughtworks.go.domain.PersistentObject)2 Element (net.sf.ehcache.Element)1