Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1073,16 +1073,13 @@ public boolean equals(Object o)
return true;
}

if (!getClass().equals(o.getClass())) {
if (o == null || !getClass().equals(o.getClass())) {
return false;
}

final TaskLockPosse that = (TaskLockPosse) o;
if (!taskLock.equals(that.taskLock)) {
return false;
}

return taskIds.equals(that.taskIds);
TaskLockPosse that = (TaskLockPosse) o;
return java.util.Objects.equals(taskLock, that.taskLock) &&
java.util.Objects.equals(taskIds, that.taskIds);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,36 @@ public void testFindLockPosseAfterRevokeWithDifferentLockIntervals() throws Entr
Assert.assertTrue(lowLockPosse.getTaskLock().isRevoked());
}

@Test
public void testLockPosseEquals()
{
final Task task1 = NoopTask.create();
final Task task2 = NoopTask.create();

TaskLock taskLock1 = new TaskLock(TaskLockType.EXCLUSIVE,
task1.getGroupId(),
task1.getDataSource(),
Intervals.of("2018/2019"),
"v1",
task1.getPriority());

TaskLock taskLock2 = new TaskLock(TaskLockType.EXCLUSIVE,
task2.getGroupId(),
task2.getDataSource(),
Intervals.of("2018/2019"),
"v2",
task2.getPriority());

TaskLockPosse taskLockPosse1 = new TaskLockPosse(taskLock1);
TaskLockPosse taskLockPosse2 = new TaskLockPosse(taskLock2);
TaskLockPosse taskLockPosse3 = new TaskLockPosse(taskLock1);

Assert.assertNotEquals(taskLockPosse1, null);
Assert.assertNotEquals(null, taskLockPosse1);
Assert.assertNotEquals(taskLockPosse1, taskLockPosse2);
Assert.assertEquals(taskLockPosse1, taskLockPosse3);
}

private Set<TaskLock> getAllLocks(List<Task> tasks)
{
return tasks.stream()
Expand Down