@@ -61,7 +61,7 @@ abstract class WorkerMain[S](stdin: InputStream = System.in, stdout: PrintStream
6161 val ec = ExecutionContext .fromExecutor(fjp)
6262
6363 // Map of request id to the runnable responsible for executing that request id
64- val activeRequests = new ConcurrentHashMap [Int , CancellableTask [Int ]](poolSize)
64+ val activeRequests = new ConcurrentHashMap [Int , ( WorkerProtocol . WorkRequest , CancellableTask [Int ]) ](poolSize)
6565
6666 def writeResponse (
6767 requestId : Int ,
@@ -136,10 +136,10 @@ abstract class WorkerMain[S](stdin: InputStream = System.in, stdout: PrintStream
136136
137137 // From the Bazel doc: "The server may send cancel requests for requests that the worker
138138 // has already responded to, in which case the cancel request must be ignored."
139- Option (activeRequests.get(requestId)).foreach { activeRequest =>
139+ Option (activeRequests.get(requestId)).foreach { case (_, workTask) =>
140140 // Cancel will wait for the thread to complete or be interrupted, so we do it in a future
141141 // to prevent blocking the worker from processing more requests
142- Future (activeRequest .cancel(mayInterruptIfRunning = mayInterruptWorkerTasks))(
142+ Future (workTask .cancel(mayInterruptIfRunning = mayInterruptWorkerTasks))(
143143 scala.concurrent.ExecutionContext .global,
144144 )
145145 }
@@ -235,9 +235,14 @@ abstract class WorkerMain[S](stdin: InputStream = System.in, stdout: PrintStream
235235 // for this requestId. If that's the case, we have a book keeping error or there are
236236 // two active requests with the same ID. Either of which is not good and something we
237237 // should just crash on.
238- if (activeRequests.putIfAbsent(requestId, workTask) != null ) {
238+ val alreadyActiveRequest = activeRequests.putIfAbsent(requestId, (request, workTask))
239+ if (alreadyActiveRequest != null ) {
240+ val (activeRequest, _) = alreadyActiveRequest
239241 throw new AnnexDuplicateActiveRequestException (
240- s " Received a WorkRequest with an already active request id: ${requestId}" ,
242+ s """ Received a WorkRequest with an already active request id: ${requestId}.
243+ Currently active request: ${activeRequest.toString}
244+ New request with the same id: ${request.toString}
245+ """ ,
241246 )
242247 } else {
243248 workTask.execute(ec)
0 commit comments