简体   繁体   English

调用get方法时来自java.util.Hashtable的AbstractMethodError

[英]AbstractMethodError from java.util.Hashtable while calling get method

We have an Object CollectedInfo , which contains a Hashtable . 我们有一个对象CollectedInfo ,其中包含一个Hashtable In our application, we populate this Hashtable , and then iterate it to perform insert operations. 在我们的应用程序中,我们填充此Hashtable ,然后对其进行迭代以执行插入操作。 Different threads used simultaneously to perform this operation. 不同的线程同时用于执行此操作。

While retrieving the value from the Hashtable , we see the AbstractMethodError exception, showing the trace from get method of Hashtable . Hashtable检索值时,我们看到AbstractMethodError异常,显示了Hashtable get方法的跟踪。 As soon as this exception comes the java application crashes. 此异常一到,Java应用程序就会崩溃。

We are not able to reproduce the exception, however we can see the same behavior in our application very consistently over a period of time. 我们无法重现异常,但是在一段时间内我们可以在应用程序中非常一致地看到相同的行为。

Below is the trace : 下面是跟踪:

SYS_ERR: Exception running task: java.lang.AbstractMethodError
SYS_ERR: java.lang.AbstractMethodError
SYS_ERR:     at java.util.Hashtable.get(Unknown Source)
SYS_ERR:     at poll.CollectedInfo.getValuesForColumn(CollectedInfo.java:1026)
SYS_ERR:     at poll.YYYMgr.saveData(YYYMgr.java:5346)
SYS_ERR:     at poll.YYYMgr.saveData(YYYMgr.java:2412)
SYS_ERR:     at poll.YYYMgr.saveData(YYYMgr.java:2250)
SYS_ERR:     at poll.CommonPollAPI.saveData(CommonPollAPI.java:579)
SYS_ERR:     at poll.XXXXData.run(XXXXData.java:76)
SYS_ERR:     at management.scheduler.WorkerThread.run(WorkerThread.java:70)

We are using the JRE 1.6.0, and the OS where this issue is reproduce is Linux Red Hat Enterprise Linux Server release 5.6 Beta (Tikanga). 我们使用的是JRE 1.6.0,重现此问题的操作系统是Linux Red Hat Enterprise Linux Server 5.6 Beta(Tikanga)。

Firstly, a Hashtable is basically a HashMap , so... 首先, Hashtable基本上是HashMap ,所以...

You have: 你有:

  • a HashMap 一个HashMap
  • Multiple threads using the HashMap concurrently 同时使用HashMap多个线程

What need is a HashMap that is coded for concurrent access. 需要的是为并发访问编码的HashMap

Fortunately, one exists already: ConcurrentHashMap . 幸运的是,已经存在一个: ConcurrentHashMap The only change you'll need to you code is to use the special thread-safe method putIfAbsent(K, V) 您需要对代码进行的唯一更改是使用特殊的线程安全方法putIfAbsent(K, V)

Take an Iterator class object and then try to get hash values. 以Iterator类对象,然后尝试获取哈希值。

//Declaration //宣言

 Iterator itr = hashtable.keySet().iterator();

// Processing //处理

 while(itr.hasNext())
 { 
    String key = (String)itr.next();  
        String value = (String)hashtable.get(key); 

           // write your desired code
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.util.Hashtable线程安全吗? - Is java.util.Hashtable thread safe? 有关java.util.Hashtable的实现细节的查询 - Queries regarding the implementation details of java.util.Hashtable 为什么在Netbeans 8中将java.util.Hashtable标记为“过时集合”? - Why java.util.Hashtable marked as 'obsolete collection' in Netbeans 8? java.util.Hashtable实现代码局部变量到元素表重新分配 - java.util.Hashtable implementation code local variable to elements table reassignment 如何理解JDK源代码中java.util.Hashtable的hashCode函数 - How to understand the hashCode function of java.util.Hashtable in the source codes of JDK 警告:[unchecked] 未经检查调用 put(K,V) 作为原始类型 java.util.Hashtable localParams.put(name, values) 的成员; - warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable localParams.put(name, values); java.lang.AbstractMethodError:在sqlite上调用createArrayOf方法时出现org.sqlite.Conn.createArrayOf错误 - java.lang.AbstractMethodError: org.sqlite.Conn.createArrayOf error while calling createArrayOf method on sqlite Java HashTable实现get方法返回null? - Java HashTable Implementation get method returning null? 从Scala使用vararg参数覆盖Java方法时发生AbstractMethodError - AbstractMethodError when overriding a Java method with vararg parameter from Scala 如何从哈希表中的(K,V)节点获取V并返回另一个类的调用方法? - How do I get a V from a (K,V) node in a hashtable back to the calling method in another class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM