java.util.HashMap中的无限循环 [英] Infinite loop in java.util.HashMap

查看:288
本文介绍了java.util.HashMap中的无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里经常封锁一些Vaadin代码,我不知道问题可能出在哪里:

 线程7892 :(state = IN_JAVA)
- java.util.HashMap.getEntry(java.lang.Object)@ bci = 61,line = 349(编译框架;信息可能不精确)
- java.util .HashMap.containsKey(java.lang.Object)@ bci = 2,line = 335(Compiled frame)
- java.util.HashSet.contains(java.lang.Object)@ bci = 5,line = 184 (编译框架)
- com.vaadin.ui.Table.unregisterPropertiesAndComponents(java.util.HashSet,java.util.HashSet)@ bci = 85,line = 1693(编译框架)
- com。 vaadin.ui.Table.refreshRenderedCells()@ bci = 992,line = 1641(Compiled frame)
- com.vaadin.ui.Table.valueChange(com.vaadin.data.Property $ ValueChangeEvent)@ bci = 23 ,line = 2897(Compiled frame)
- com.vaadin.data.util.IndexedContainer.firePropertyValueChange(com.vaadin.data.util.IndexedContainer $ IndexedContainerProperty)@ bci = 140,line = 553(Compiled frame)
- com.vaadin.data.util.IndexedC ontainer.access $ 1000(com.vaadin.data.util.IndexedContainer,com.vaadin.data.util.IndexedContainer $ IndexedContainerProperty)@ bci = 2,line = 64(Compiled frame)
- com.vaadin.data。 util.IndexedContainer $ IndexedContainerProperty.setValue(java.lang.Object)@ bci = 202,line = 915(Compiled frame)
- com.aimprosoft.wavilon.backgroundthreads.ChangeCdrThread.insertNewPersonIntoTable(com.aimprosoft.wavilon.model .Person,com.vaadin.ui.Horizo​​ntalLayout,com.aimprosoft.wavilon.ui.menuitems.CallContent,com.vaadin.ui.Table)@ bci = 924,line = 208(Interpreted frame)
- com。 aimprosoft.wavilon.backgroundthreads.ChangeCdrThread $ RepaintTableThread.run()@ bci = 622,line = 446(编译框架)

有人可以提出任何方法来进一步调试此问题吗?这个问题很少发生,而且很难再现。

解决方案

基于代码中的位置,唯一的我能想到的解释是,有多个线程在没有正确同步的情况下访问和更新 HashMap 。这可能会导致映射的数据结构被破坏,并可能导致无限循环。



我无法想象为什么 java.util.HashMap.getEntry 会被阻塞。它不会做任何同步或任何I / O。






Roland Illig评论:


行号确实表明代码挂在 e = e.next 循环之一中。


支持我的假设。由两个(或更多)线程执行的哈希表上的特定操作序列已经导致在其中一个哈希链中创建循环/循环。发生这种破坏是因为执行操作的线程之间的同步不足。这种事情很少发生,但一旦发生,腐败就不会消失。



没有深入研究Vaadin源代码,我可以不能确切地告诉你是Vaadin的bug还是你使用Vaadin的方式的错误。任何解释都是合理的。

更新



基于这篇文章(在下面的评论中提供),我会说这很可能是一个问题就像你的应用程序正在同步(或不)。


I have some Vaadin code blocking very often here, and I have no idea what the problem can be:

Thread 7892: (state = IN_JAVA)
 - java.util.HashMap.getEntry(java.lang.Object) @bci=61, line=349 (Compiled frame; information may be imprecise)
 - java.util.HashMap.containsKey(java.lang.Object) @bci=2, line=335 (Compiled frame)
 - java.util.HashSet.contains(java.lang.Object) @bci=5, line=184 (Compiled frame)
 - com.vaadin.ui.Table.unregisterPropertiesAndComponents(java.util.HashSet, java.util.HashSet) @bci=85, line=1693 (Compiled frame)
 - com.vaadin.ui.Table.refreshRenderedCells() @bci=992, line=1641 (Compiled frame)
 - com.vaadin.ui.Table.valueChange(com.vaadin.data.Property$ValueChangeEvent) @bci=23, line=2897 (Compiled frame)
 - com.vaadin.data.util.IndexedContainer.firePropertyValueChange(com.vaadin.data.util.IndexedContainer$IndexedContainerProperty) @bci=140, line=553 (Compiled frame)
 - com.vaadin.data.util.IndexedContainer.access$1000(com.vaadin.data.util.IndexedContainer, com.vaadin.data.util.IndexedContainer$IndexedContainerProperty) @bci=2, line=64 (Compiled frame)
 - com.vaadin.data.util.IndexedContainer$IndexedContainerProperty.setValue(java.lang.Object) @bci=202, line=915 (Compiled frame)
 - com.aimprosoft.wavilon.backgroundthreads.ChangeCdrThread.insertNewPersonIntoTable(com.aimprosoft.wavilon.model.Person, com.vaadin.ui.HorizontalLayout, com.aimprosoft.wavilon.ui.menuitems.CallContent, com.vaadin.ui.Table) @bci=924, line=208 (Interpreted frame)
 - com.aimprosoft.wavilon.backgroundthreads.ChangeCdrThread$RepaintTableThread.run() @bci=622, line=446 (Compiled frame)

Can somebody suggest any way to further debug this issue? The problem happens very rarely, and it is quite difficult to reproduce.

解决方案

Based on where it is in the code, the only explanation I can think of is that there are multiple threads accessing and updating that HashMap without synchronizing properly. This can cause the map's data structures to be corrupted, and could result in an infinite loop.

I can't think of any other reason why java.util.HashMap.getEntry would block. It doesn't do any synchronization or any I/O.


Roland Illig comments:

The line number indeed suggests that the code hangs in one of the e = e.next loops.

That supports my hypothesis. A particular sequence of operations on the hash table performed by two (or more) threads has resulted in the creation of a loop / cycle in one of the hash chains. This corruption has happened because there was inadequate synchronization between the threads performing the operations. It is the kind of thing that happens very rarely, but once it has happened the corruption won't go away.

Without looking deeply into the Vaadin source code, I can't tell you exactly whether it is a Vaadin bug, or a bug in the way that you are using Vaadin. Either explanation is plausible.

UPDATE

Based on this article (provided in a comment below), I would say that it is most likely a problem in the way that your application is synchronizing (or not).

这篇关于java.util.HashMap中的无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆