Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SynchronizedQueue doesn't synchronize foreach (and many other methods) #4916

Closed
scabug opened this issue Aug 16, 2011 · 3 comments
Closed

SynchronizedQueue doesn't synchronize foreach (and many other methods) #4916

scabug opened this issue Aug 16, 2011 · 3 comments

Comments

@scabug
Copy link

scabug commented Aug 16, 2011

val queue = new SynchronizedQueue[(A,B)]

for( (a,_) <- queue ){
	// ...
}


java.util.NoSuchElementException
	at scala.collection.mutable.LinkedListLike$class.head(LinkedListLike.scala:69)
	at scala.collection.mutable.LinkedList.head(LinkedList.scala:41)
	at scala.collection.mutable.MutableList.head(MutableList.scala:51)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.mutable.MutableList.foreach(MutableList.scala:28)
	at scala.collection.TraversableLike$class.filter(TraversableLike.scala:212)
	at scala.collection.mutable.MutableList.filter(MutableList.scala:28)
	at line 3 in the code example

the queue is also accessed by other Actors.

@scabug
Copy link
Author

scabug commented Aug 16, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4916?orig=1
Reporter: Arne Döring (krux02)
Affected Versions: 2.9.0-1
See #4290
Duplicates #4290

@scabug
Copy link
Author

scabug commented May 12, 2012

@retronym said (edited on May 12, 2012 12:41:13 PM UTC):
This class of bug seems almost guaranteed in all the SynchronizedXxx collection proxies -- there are no checks in place to ensure every method is overridden with synchronized wrapper.

An admission of this in a TODO comment: https://github.com/scala/scala/blob/master/src/library/scala/collection/mutable/SynchronizedMap.scala#L57

Whacking a solitary mole:

#4326

@scabug
Copy link
Author

scabug commented Dec 12, 2012

@retronym said:
Merging with #4290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant