@@ -61,7 +61,7 @@ abstract class WorkerMain[S](stdin: InputStream = System.in, stdout: PrintStream
61
61
val ec = ExecutionContext .fromExecutor(fjp)
62
62
63
63
// 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)
65
65
66
66
def writeResponse (
67
67
requestId : Int ,
@@ -136,10 +136,10 @@ abstract class WorkerMain[S](stdin: InputStream = System.in, stdout: PrintStream
136
136
137
137
// From the Bazel doc: "The server may send cancel requests for requests that the worker
138
138
// 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) =>
140
140
// Cancel will wait for the thread to complete or be interrupted, so we do it in a future
141
141
// to prevent blocking the worker from processing more requests
142
- Future (activeRequest .cancel(mayInterruptIfRunning = mayInterruptWorkerTasks))(
142
+ Future (workTask .cancel(mayInterruptIfRunning = mayInterruptWorkerTasks))(
143
143
scala.concurrent.ExecutionContext .global,
144
144
)
145
145
}
@@ -235,9 +235,14 @@ abstract class WorkerMain[S](stdin: InputStream = System.in, stdout: PrintStream
235
235
// for this requestId. If that's the case, we have a book keeping error or there are
236
236
// two active requests with the same ID. Either of which is not good and something we
237
237
// 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
239
241
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
+ """ ,
241
246
)
242
247
} else {
243
248
workTask.execute(ec)
0 commit comments