Can't Interrupt reading thread while Executing queue
Kolyall opened this issue · 1 comments
Kolyall commented
Here is code of ObdGatewayService.class
...........
protected void executeQueue() throws InterruptedException {
Log.d(TAG, "Executing queue..");
while (!Thread.currentThread().isInterrupted()) {
ObdCommandJob job = null;
try {
job = jobsQueue.take();`
// log job
Log.d(TAG, "Taking job[" + job.getId() + "] from queue..");
if (job.getState().equals(ObdCommandJobState.NEW)) {
Log.d(TAG, "Job state is NEW. Run it..");
job.setState(ObdCommandJobState.RUNNING);
job.getCommand().run(sock.getInputStream(), sock.getOutputStream());`
...........
BUG: If OutputStream is closed or InputStream is closed before run of ObdCommand by this line: job.getCommand().run(sock.getInputStream(), sock.getOutputStream());
"receiving data..." command doesn't stop. No any Exception. Log stops on line :
I/ObdGatewayService: Taking job[45] from queue..
E/ObdGatewayService: Job state is NEW. Run it..
May be you can add a timeout for read?
To reproduce the issue:
- Connect to device,
- Run the ObdGatewayService, -> All works fine
- Go away from your car, or turn off ELM327 device from your car
[bug] Reproduced
pires commented
Interesting! Thank you for reporting, will look into it.