Netflix/curator — Issue #15: Issues with runtime Dependency on guava version > r09
Author: inders
Created: 2012-01-05 12:36:05+00:00
State: open

i am using Curator leader recipe in my project (https://github.com/InMobi/data-bus/) which is WIP and faced the following

1. If i include any version of guava > r09 i.e. 10.0.1 it fails with the following exception

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Ljava/util/concurrent/ExecutorService;
at com.netflix.curator.framework.recipes.leader.LeaderSelector.(LeaderSelector.java:62)

to avoid this i tried using the other constructor of LeaderSelector which allows me to pass the ExecutorService instead of using the G! one.

public LeaderSelector(CuratorFramework client, String mutexPath, ThreadFactory threadFactory, Executor executor, LeaderSelectorListener listener)

again resulted in the same issue as ListenerContainer.addListener method uses the G! MoreExecutors irrespective of user providing his own in the constructor.
Reference Code -
@Override
public void addListener(T listener)
{
addListener(listener, MoreExecutors.sameThreadExecutor());
}

After some struggle i was able to get it working with the following

com.google.guava
guava
r09

Suggestions
1. Documenting the exact version of this runtime dependency would be helpful
2. If the user has supplied it's own executorservice it shouldn't try using the G! version.