java.util.concurrent.ConcurrentHashMap.get()抛出StackOverflowError

时间:2017-06-08 09:05:04

标签: android stack-overflow

在我的Android应用中,我使用了ConcurrentHashMap。只是一个get操作,然后叠加流程。

设备型号:NX511J Android操作系统:5.1.1 Android SDK:22

这是完整的堆栈跟踪:

java.lang.StackOverflowError: stack size 1036KB

(13000 same stack trace)

  at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1507)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap$ForwardingNode.find(ConcurrentHashMap.java:1515)
    at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:754)
    at com.tmall.wireless.minsk.internal.store.impl.ConfigStoreImpl.c(ConfigStoreImpl.java:526)
    at com.tmall.wireless.minsk.internal.store.impl.ConfigStoreImpl.a(ConfigStoreImpl.java:461)
    at mwo.a(MinskImpl.java:265)
    at jfd.a(TMConfigCenterManager.java:186)
    at ogf.c(TMRewriteEngine.java:177)
    at ogf$1.run(TMRewriteEngine.java:141)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:818)

源代码(我认为它没有使用问题):

private final ConcurrentMap<String, Module> immutableLocalCache = new ConcurrentHashMap<>();
    private Module getFromLocal(String moduleName) {
        Module module = immutableLocalCache.get(moduleName);// Stack over flow
        if (null != module) {
            return module;
        }
        //...
        try {
            Module ret = MinskDataConvertUtils.createMinskModule(data);
            immutableLocalCache.put(ret.name, ret);
            return ret;
        } catch (Exception e) {
            LogUtils.exception(e);
            return null;
        }
    }

1 个答案:

答案 0 :(得分:0)

堆栈溢出的常见原因是您在循环中传递的错误递归调用或条件。通常,这是在递归函数没有正确的终止条件时引起的,因此最终会自动调用它自己。

可能是您正在迭代或使用递归来获取操作。如果您正在使用循环检查您已经给出的条件。 仍然存在错误,然后发布您的代码。