简体   繁体   中英

On upgrading Guava to the latest 23.5 getting NoSuchMethodError for Preconditions.checkArgument

On upgrading Guava to the latest 23.5-jre from 18.0 I am getting an exception like below

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
    at com.van.common.VanExecutors.getSpec(VanExecutors.java:91)
    at com.van.common.VanExecutors.newFixedSizeExecutor(VanExecutors.java:114)
    at com.van.storage.config.ConfigStoreFactory.getOrCreateUncachedStore(ConfigStoreFactory.java:56)
    at com.van.storage.config.ConfigStoreFactory.getOrCreateStore(ConfigStoreFactory.java:74)
    at com.van.storage.config.PolicyManager.loadFromSystemProperties(PolicyManager.java:79)
    at com.van.tools.metric.HbaseMetricStoreSetup.main(HbaseMetricStoreSetup.java:25)

The relevant code

private ExecutorSpec getSpec(String executorName) {
        Preconditions.checkArgument(isValid(), "Not initialized");
        Preconditions.checkArgument(NullOrEmpty.isFalse(executorName), "No executor name given");
        Preconditions.checkArgument(POOL_NAME_PATTERN.matcher(executorName).matches(), "Executor name %s must end with -exec", executorName);
        for (ExecutorSpec spec : executorsSpec.getExecutorSpecList()) {
            if (spec.getName().equalsIgnoreCase(executorName)) return spec;
        }
        return null;
    }

As per the stacktrace line 91 is the last Preconditions check.

Can someone let me know what is going wrong?

在我看来,方法isValid()返回一个String (这个boolean 改变了吗?),但是应该是一个boolean (在版本18中也是如此 )。

为了解决此问题,我在CLASSPATH( export CLASSPATH=<guava-23.5>;$CLASSPATH )加上Guava 23.5 jre的前缀。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM