Skip to content

Commit

Permalink
Potentially fix NPE with bulk cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Frogbots4634 committed Feb 8, 2020
1 parent 60aac01 commit db88b6f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Hardware/src/main/java/com/qualcomm/hardware/lynx/LynxModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1368,24 +1368,26 @@ public double getAnalogInputVoltage(int inputZ, VoltageUnit unit)
*/
public BulkData getBulkData()
{
clearBulkCache();

LynxGetBulkInputDataCommand command = new LynxGetBulkInputDataCommand(this);
try
{
LynxGetBulkInputDataResponse response = command.sendReceive();
synchronized (bulkCachingLock)
{
clearBulkCache();

LynxGetBulkInputDataCommand command = new LynxGetBulkInputDataCommand(this);
try
{
lastBulkData = new BulkData(response);
return lastBulkData;
LynxGetBulkInputDataResponse response = command.sendReceive();
lastBulkData = new BulkData(response);
return lastBulkData;
}
catch (InterruptedException|RuntimeException|LynxNackException e)
{
handleException(e);
}
}
catch (InterruptedException|RuntimeException|LynxNackException e)
{
handleException(e);
}

return LynxUsbUtil.makePlaceholderValue(new BulkData(new LynxGetBulkInputDataResponse(this)));
BulkData placeholder = LynxUsbUtil.makePlaceholderValue(new BulkData(new LynxGetBulkInputDataResponse(this)));
lastBulkData = placeholder;
return placeholder;
}
}

/**
Expand Down

0 comments on commit db88b6f

Please sign in to comment.