Skip to content

Commit

Permalink
Make AllocatedPersistentTask members volatile (elastic#2297)
Browse files Browse the repository at this point in the history
These members are default initialized on contruction and then set by the
init() method.  It's possible that another thread accessing the object
after init() is called could still see the null/0 values, depending on how
the compiler optimizes the code.
  • Loading branch information
droberts195 authored and martijnvg committed Jan 31, 2018
1 parent b0de3c3 commit 7313ad5
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
* Represents a executor node operation that corresponds to a persistent task
*/
public class AllocatedPersistentTask extends CancellableTask {
private String persistentTaskId;
private long allocationId;
private volatile String persistentTaskId;
private volatile long allocationId;

private final AtomicReference<State> state;
@Nullable
private Exception failure;
private volatile Exception failure;

private PersistentTasksService persistentTasksService;
private Logger logger;
private TaskManager taskManager;
private volatile PersistentTasksService persistentTasksService;
private volatile Logger logger;
private volatile TaskManager taskManager;


public AllocatedPersistentTask(long id, String type, String action, String description, TaskId parentTask) {
Expand Down

0 comments on commit 7313ad5

Please sign in to comment.