Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/15371#discussion_r82467368
--- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala
---
@@ -344,15 +338,20 @@ private[spark] class BlockStatusesAccumulator
override def add(v: (BlockId, BlockStatus)): Unit = _seq.add(v)
override def merge(
- other: AccumulatorV2[(BlockId, BlockStatus), java.util.List[(BlockId,
BlockStatus)]]): Unit = {
+ other: AccumulatorV2[(BlockId, BlockStatus), List[(BlockId,
BlockStatus)]]): Unit = {
other match {
- case o: BlockStatusesAccumulator => _seq.addAll(o.value)
+ case o: BlockStatusesAccumulator => o.value.foreach(_seq.add)
case _ => throw new UnsupportedOperationException(
s"Cannot merge ${this.getClass.getName} with
${other.getClass.getName}")
}
}
- override def value: java.util.List[(BlockId, BlockStatus)] = _seq
+ // `asScala` accesses the internal values using `java.util.Iterator` so
needs to be synchronized
+ override def value: List[(BlockId, BlockStatus)] = {
+ _seq.synchronized {
--- End diff --
`_seq.synchronized` is wrong. `Collections.synchronizedList` uses its
internal `mutex` to lock instead of `this`.
Why changes them to Scala List? Just change this one to
`java.util.Collections.unmodifiableList(new ArrayList[(BlockId,
BlockStatus)](_seq))` should be enough.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]