ehcache / ehcache-jcache

The Ehcache 2.x implementation of JSR107 (JCACHE)
Other
91 stars 48 forks source link

JCacheManager.unwrap #20

Closed Mobe91 closed 10 years ago

Mobe91 commented 10 years ago

Hi, I think someone forgot to return the casted cacheManager. So instead of

@Override
    public <T> T unwrap(final Class<T> clazz) {
        if(clazz.isAssignableFrom(getClass())) {
            return clazz.cast(this);
        }
        if(clazz.isAssignableFrom(cacheManager.getClass())) {
            clazz.cast(cacheManager);
        }
        throw new IllegalArgumentException();
    }

it should be

@Override
    public <T> T unwrap(final Class<T> clazz) {
        if(clazz.isAssignableFrom(getClass())) {
            return clazz.cast(this);
        }
        if(clazz.isAssignableFrom(cacheManager.getClass())) {
            return clazz.cast(cacheManager);
        }
        throw new IllegalArgumentException();
    }

Or am I missing something?

alexsnaps commented 10 years ago

Oh yes! Who would have thought the TCK wouldn't catch that ;)