aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject aurora git commit: Avoid unintentional use of TaskStatus.Reason default value.
Date Wed, 01 Jul 2015 17:53:42 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 88f887587 -> 1024a8579


Avoid unintentional use of TaskStatus.Reason default value.

Bugs closed: AURORA-1327

Reviewed at https://reviews.apache.org/r/35928/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/1024a857
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/1024a857
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/1024a857

Branch: refs/heads/master
Commit: 1024a8579e201e648d86d49ff97c4542cc710956
Parents: 88f8875
Author: Bill Farner <wfarner@apache.org>
Authored: Wed Jul 1 10:53:12 2015 -0700
Committer: Bill Farner <wfarner@apache.org>
Committed: Wed Jul 1 10:53:12 2015 -0700

----------------------------------------------------------------------
 .../scheduler/mesos/MesosSchedulerImpl.java     |  2 +-
 .../scheduler/mesos/MesosSchedulerImplTest.java | 32 +++++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/1024a857/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
index 33749de..6f06693 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
@@ -226,7 +226,7 @@ public class MesosSchedulerImpl implements Scheduler {
     eventSink.post(new TaskStatusReceived(
         status.getState(),
         Optional.fromNullable(status.getSource()),
-        Optional.fromNullable(status.getReason()),
+        status.hasReason() ? Optional.of(status.getReason()) : Optional.absent(),
         Optional.fromNullable(status.getTimestamp()).transform(SECONDS_TO_MICROS)));
 
     try {

http://git-wip-us.apache.org/repos/asf/aurora/blob/1024a857/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
index f08c799..ea96f46 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
@@ -109,28 +109,25 @@ public class MesosSchedulerImplTest extends EasyMockTest {
               .setMode(NONE)
               .setAttributes(ImmutableSet.<Attribute>of())));
 
-  private static final TaskStatus.Builder STATUS_BUILDER = TaskStatus.newBuilder()
+  private static final TaskStatus STATUS_NO_REASON = TaskStatus.newBuilder()
       .setState(TaskState.TASK_RUNNING)
       .setSource(Source.SOURCE_SLAVE)
-      // Only testing data plumbing, this field with TASK_RUNNING would not normally happen,
-      .setReason(Reason.REASON_COMMAND_EXECUTOR_FAILED)
       .setMessage("message")
       .setTimestamp(1D)
-      .setTaskId(TaskID.newBuilder().setValue("task-id").build());
+      .setTaskId(TaskID.newBuilder().setValue("task-id").build())
+      .build();
 
-  private static final TaskStatus STATUS = STATUS_BUILDER.build();
+  private static final TaskStatus STATUS = STATUS_NO_REASON
+      .toBuilder()
+      // Only testing data plumbing, this field with TASK_RUNNING would not normally happen,
+      .setReason(Reason.REASON_COMMAND_EXECUTOR_FAILED)
+      .build();
 
-  private static final TaskStatus STATUS_RECONCILIATION = STATUS_BUILDER
+  private static final TaskStatus STATUS_RECONCILIATION = STATUS_NO_REASON
+      .toBuilder()
       .setReason(Reason.REASON_RECONCILIATION)
       .build();
 
-  private static final TaskStatusReceived PUBSUB_EVENT = new TaskStatusReceived(
-      STATUS.getState(),
-      Optional.of(STATUS.getSource()),
-      Optional.of(STATUS.getReason()),
-      Optional.of(1000000L)
-  );
-
   private static final TaskStatusReceived PUBSUB_RECONCILIATION_EVENT = new TaskStatusReceived(
       STATUS_RECONCILIATION.getState(),
       Optional.of(STATUS_RECONCILIATION.getSource()),
@@ -261,7 +258,12 @@ public class MesosSchedulerImplTest extends EasyMockTest {
     new StatusFixture() {
       @Override
       void expectations() {
-        eventSink.post(PUBSUB_EVENT);
+        eventSink.post(new TaskStatusReceived(
+            STATUS.getState(),
+            Optional.of(STATUS.getSource()),
+            Optional.of(STATUS.getReason()),
+            Optional.of(1000000L)
+        ));
         statusHandler.statusUpdate(status);
         expectLastCall().andThrow(new StorageException("Injected."));
       }
@@ -377,7 +379,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       eventSink.post(new TaskStatusReceived(
           status.getState(),
           Optional.fromNullable(status.getSource()),
-          Optional.fromNullable(status.getReason()),
+          status.hasReason() ? Optional.of(status.getReason()) : Optional.absent(),
           Optional.of(1000000L)
       ));
       statusHandler.statusUpdate(status);


Mime
View raw message