Skip to content

RuntimeException in MemcacheClientWrapperΒ #88

@artemSpb96

Description

@artemSpb96

OperationFuture.get() from package 'net.spy.memcached.internal' method throws TimeoutException wrapped in RuntimeException

public T get() throws InterruptedException, ExecutionException {
    try {
      return get(timeout, TimeUnit.MILLISECONDS);
    } catch (TimeoutException e) {
      throw new RuntimeException("Timed out waiting for operation", e);
    }
  }

Add operations in MemcacheClientWrapper don't catch it:

@Override
    public boolean add(final String key, final int exp, final Object value) throws TimeoutException, CacheException {
        Future<Boolean> f = null;
        try {
            f = memcachedClient.add(key, exp, value);
            return f.get();
        } catch (InterruptedException | ExecutionException e) {
            cancel(f);
            throw new CacheException(e);
        }
    }

    @Override
    public <T> boolean add(final String key, final int exp, final T value, final CacheTranscoder transcoder) throws TimeoutException,
            CacheException {
        Future<Boolean> f = null;
        try {
            f = memcachedClient.add(key, exp, value, getTranscoder(transcoder));
            return f.get();
        } catch (InterruptedException | ExecutionException e) {
            cancel(f);
            throw new CacheException(e);
        }
    }

It would be great to catch it as in get methods:

@Override
    public Object get(final String key) throws TimeoutException, CacheException {
        try {
            return memcachedClient.get(key);
        } catch (RuntimeException e) {
            if (translateException(e)) {
                throw new CacheException(e);
            } else if (e.getCause() instanceof TimeoutException) {
                throw (TimeoutException) e.getCause();
            }

            throw e;
        }
    }

Lib dependencies:

com.google.code.simple-spring-memcached:spring-cache:4.1.2
com.google.code.simple-spring-memcached:spymemcached-provider:4.1.2
net.spy:spymemcached:2.12.3

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions