我试着用Java8编写代码。我用IDEA运行它。当我在云服务器上开发它时,它遇到了以下异常:
java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1380)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
List<Data> validDOList = DataDOList.stream()
.filter(Objects::nonNull)
.filter(dataDO -> dataDO.getId() % 2 == 0)
.collect(Collectors.toList());
-------更新-------------------------------------------------------------------
List<SkuPriceDataDO> validSkuPriceDOList = skuPriceDataDOList.stream()
.filter(Objects::nonNull)
.filter(skuPriceDataDO -> isValidSkuPriceDataDO(skuRealTimeDataDoMap.get(ESUtils
.generateDocId(skuPriceDataDO.getPoiId(),
skuPriceDataDO.getSkuId(), skuPriceDataDO.getScheduleDate())), skuPriceDataDO))
.collect(Collectors.toList());
筛选方法详细信息
private boolean isValidSkuPriceDataDO(SkuRealTimeDataDO skuRealTimeDataDO, SkuPriceDataDO skuPriceDataDO) {
if (skuRealTimeDataDO == null || skuPriceDataDO == null) {
return false;
}
boolean equal = StringUtils.equals(skuPriceDataDO.getSpecUnit(), skuRealTimeDataDO.getSpecUnit())
&& Objects.equals(skuPriceDataDO.getSpecValue(), skuRealTimeDataDO.getSpecValue())
&& Objects.equals(skuPriceDataDO.getAvgPrice7dWholesale(), skuRealTimeDataDO.getAvgPrice7dWholesale())
&& Objects.equals(skuPriceDataDO.getAvgPrice1dWholesale(), skuRealTimeDataDO.getAvgPrice1dWholesale())
&& Objects.equals(skuPriceDataDO.getAvgPrice1dCx(), skuRealTimeDataDO.getAvgPrice1dCx())
&& Objects.equals(skuPriceDataDO.getAvgPrice7dCx(), skuRealTimeDataDO.getAvgPrice7dCx())
&& Objects.equals(skuPriceDataDO.getAvgPrice1dDd(), skuRealTimeDataDO.getAvgPrice1dDd())
&& Objects.equals(skuPriceDataDO.getAvgPrice7dDd(), skuRealTimeDataDO.getAvgPrice7dDd());
return !equal;
}
某些线程试图访问和mpdify列表
导致的错误,这不是并发的或线程安全的,导致内存修改数据发生冲突。
您应该使用一些线程安全的列表类型,如CopyOnWriteArrayList
或LinkedBlockingQueue
。使用CopyOnWriteArrayList
而不是List
在Eclipse PDT中运行PHPUnit测试时,右键单击test文件夹并选择run As>PHPUnit Testm 生成此错误: 我导航到Eclipse日志文件,找到了以下文本: Eclipse.buildid=4.8.0.i20180611-0500 参数:-product org.eclipse.epp.package.php.product命令行 参数:-OS win32-WS win
问题内容: 当我在Embedabble中有一个CollectionOfElements时,我似乎得到了ConcurrentModificationException。 如果想要这样,但是如果我将Route从Embedabble更改为Entity,则一切正常。我什至尝试添加@Version,但这似乎不起作用。 这是我班的摘录。Kart.java: Route.java: Coordinates.ja
ConcurrentModificationException java.util.arrayList$itr.checkforcoModification(arrayList.java:901)java.util.arrayList$itr.next(arrayList.java:851)servlets.addcart.doget
问题内容: 在我通过Admob广告中介添加MoPub的最新版本中,我在崩溃日志中看到了一堆ConcurrentModificationException。所有这些似乎都是本机代码,我使用的是与广告相关的所有最新版本以及与Google / android相关的所有库。有人遇到过吗? 这是直到BaseActivity的第21行的代码: 这就是代码,直到最近的最近70行 问题答案: 就我们而言,我们只会
问题内容: final Multimap terms = getTerms(bq); for (Term t : terms.keySet()) { Collection C = new HashSet(terms.get(t)); if (!C.isEmpty()) { for (Iterator it = C.iterator(); it.hasNext();) { BooleanClause