Balzanka / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Remove synchronized keyword from ServiceManager.ServiceListener#startupTimeMillis() #1340

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the private class ServiceListener inside of ServiceManager, the 
startupTimeMillis() function is synchronized on the instance of the 
ServiceListener. As far as I can tell, this is the only time synchronized is 
used on the ServiceListener instance. There is a Stopwatch instance inside the 
class, but it is guarded by synchronizing on the instance of Stopwatch. Indeed, 
startupTimeMillis() synchronizes on the watch as well as itself. Therefore, I 
think the method level "synchronized" can be removed.

Original issue reported on code.google.com by Sailor...@gmail.com on 14 Mar 2013 at 11:12

GoogleCodeExporter commented 9 years ago

Original comment by kurt.kluever on 14 Mar 2013 at 11:17

GoogleCodeExporter commented 9 years ago
Good find!  This is definitely a mistake and will be removed.  Interestingly it 
also looks like this could cause a deadlock since startuptimes calls 
synchronized(this) and then synchronized(watch) but finishedStarting calls 
synchronized(watch) and then startuptimes, so i think this is a classic lock 
ordering bug.  Luckily one of the locks can just be dropped so it is easy to 
fix :)

Thanks for the report!

Original comment by lu...@google.com on 14 Mar 2013 at 11:35

GoogleCodeExporter commented 9 years ago
This has been fixed internally and should make it out in the next sync

Original comment by lu...@google.com on 15 Mar 2013 at 7:15

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08