[英]Java BeanMap Iterator throws UnsupportedOperationException on iterator.remove()
I'm having a problem debugging an application which uses an iterator to cycle through the entries in a beanmap. 我在调试使用迭代器在beanmap中的条目之间循环的应用程序时遇到问题。 When I use the remove() function on the iterator, the application crashes, and I cannot figure out why.
当我在迭代器上使用remove()函数时,应用程序崩溃,并且我无法弄清原因。 It used to work fine.
过去工作正常。
The application has been running fine for over a year now without any issues. 该应用程序已经运行了一年多,没有任何问题。 Perhaps the .remove() function was never really called as it is inside an if clause, but I still think it should work fine.
也许从未真正调用过.remove()函数,因为它位于if子句中,但我仍然认为它应该可以正常工作。
Here's the code: 这是代码:
BeanMap bm = new BeanMap(pKzlGd);
Iterator entries = bm.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) entries.next();
if (entry.getValue() instanceof Class) {
entries.remove();
}
}
This is basically the StackTrace error I get: 这基本上是我得到的StackTrace错误:
Stack trace: javax.faces.FacesException: #{aopUpload.upload}: java.lang.UnsupportedOperationException: remove() is not supported
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at si.nkbm.bilbon.net.ExceptionActionListener.processAction(ExceptionActionListener.java:24)
at javax.faces.component.UICommand.broadcast(UICommand.java:387)
at org.ajax4jsf.component.UIInclude.broadcast(UIInclude.java:170)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
As far as can see you use BeanMap . 据您所见,您使用BeanMap 。 It seems that iterators provided by that
Map
don't support removing of entries. 该
Map
提供的迭代器似乎不支持删除条目。 I suppose you've never passed through the if
statement before. 我想您之前从未通过过
if
语句。 This behavior is expected. 此行为是预期的。 Documentation mentions that it's not actually allowed to remove entries.
文档中提到实际上不允许删除条目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.