[tor-bugs] #24824 [Metrics/Website]: Either sleep() or wait() in a synchronized block

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Jan 8 10:28:56 UTC 2018


#24824: Either sleep() or wait() in a synchronized block
---------------------------------+--------------------------
     Reporter:  karsten          |      Owner:  metrics-team
         Type:  defect           |     Status:  new
     Priority:  Medium           |  Milestone:
    Component:  Metrics/Website  |    Version:
     Severity:  Normal           |   Keywords:
Actual Points:                   |  Parent ID:
       Points:                   |   Reviewer:
      Sponsor:                   |
---------------------------------+--------------------------
 While looking into #24792, I found that we're calling `this.wait()`
 [https://gitweb.torproject.org/metrics-
 web.git/tree/src/main/java/org/torproject/metrics/web/CollectorDirectoryProvider.java#n43
 here] without being in a synchronized method or block. That gets us a
 `IllegalMonitorStateException`. The only reason why we never ran into one
 of those (or never noticed?) is that most clients first open
 `/collector.html` which triggers an `index.json` file download in the
 background before opening actual directory listing pages.

 We should fix this. Two options: use `Thread.sleep()` instead of
 `this.wait()`, or wrap `this.wait()` inside `synchronized` possibly even
 combined with `this.notifyAll()`. I'd say let's do the latter. I'm
 attaching a quickly tested branch in a second.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24824>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list