]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8987 remove use of Guava Optional in CE tables related classes
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 29 Mar 2017 12:23:52 +0000 (14:23 +0200)
committerEric Hartmann <hartmann.eric@gmail.Com>
Thu, 27 Apr 2017 07:23:18 +0000 (09:23 +0200)
17 files changed:
server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueue.java
server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepository.java
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImpl.java
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerCallableImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryRule.java
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerCallableImplTest.java
server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeActivityDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeQueueDao.java
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
server/sonar-server/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
server/sonar-server/src/main/java/org/sonar/server/ce/ws/ActivityAction.java
server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java
server/sonar-server/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java

index 01f5341f7644570b3996bca31372b7e8f8e103c1..42447633920b4ca546753cc66ff2e829d713444c 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.queue;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.sonar.ce.queue.CeQueue;
 import org.sonar.ce.queue.CeTask;
index bcd6f0abccf884587af172fa4291926d7a56c813..8f899d4b2e6a3bdf7982b6ee128be9157c7b9715 100644 (file)
  */
 package org.sonar.ce.queue;
 
-import com.google.common.base.Optional;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
@@ -68,7 +68,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
     requireNonNull(workerUuid, "workerUuid can't be null");
 
     if (peekPaused.get()) {
-      return Optional.absent();
+      return Optional.empty();
     }
     try (DbSession dbSession = dbClient.openSession(false)) {
       Optional<CeQueueDto> dto = dbClient.ceQueueDao().peek(dbSession, workerUuid, MAX_EXECUTION_COUNT);
@@ -77,7 +77,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
         task = loadTask(dbSession, dto.get());
         queueStatus.addInProgress();
       }
-      return Optional.fromNullable(task);
+      return Optional.ofNullable(task);
 
     }
   }
index 7fbbfa3f3f71ee0ba9e7e3eb09c645517b1beb7c..83fb0d01f01600cb553d5f08ec5e89ebb08e84b2 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.taskprocessor;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.sonar.ce.queue.CeTask;
 import org.sonar.ce.taskprocessor.CeTaskProcessor;
 
index 24a2bf07530325fca3645ed3a6ac8ea3a692c6c5..b96a8e1783fd9f0bee1311edbc5f6f2a8ee735f7 100644 (file)
@@ -21,13 +21,13 @@ package org.sonar.ce.taskprocessor;
 
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.sonar.ce.queue.CeTask;
 import org.sonar.ce.taskprocessor.CeTaskProcessor;
@@ -52,7 +52,7 @@ public class CeTaskProcessorRepositoryImpl implements CeTaskProcessorRepository
 
   @Override
   public Optional<CeTaskProcessor> getForCeTask(CeTask ceTask) {
-    return Optional.fromNullable(taskProcessorByCeTaskType.get(ceTask.getType()));
+    return Optional.ofNullable(taskProcessorByCeTaskType.get(ceTask.getType()));
   }
 
   private static Map<String, CeTaskProcessor> indexTaskProcessors(CeTaskProcessor[] taskProcessors) {
index 5bb5a04706801b6de9f05a660c18a067579b1117..517a0a7651dac283fb820d5f7dbace52ca7bf7ec 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.ce.taskprocessor;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
@@ -67,7 +67,7 @@ public class CeWorkerCallableImpl implements CeWorkerCallable {
     } catch (Exception e) {
       LOG.error("Failed to pop the queue of analysis reports", e);
     }
-    return Optional.absent();
+    return Optional.empty();
   }
 
   private void executeTask(CeTask task) {
index 2bf444730cb3e4bb81b7d186415b3a6146b242c8..071bd177845852977c403975167222a5d1f2249f 100644 (file)
  */
 package org.sonar.ce.queue;
 
-import com.google.common.base.Optional;
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.util.List;
+import java.util.Optional;
 import java.util.Random;
 import javax.annotation.Nullable;
-import org.assertj.guava.api.Assertions;
+import org.hamcrest.Matchers;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -49,7 +49,6 @@ import org.sonar.server.organization.DefaultOrganizationProvider;
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.Matchers.startsWith;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -226,7 +225,7 @@ public class InternalCeQueueImplTest {
     underTest.remove(peek.get(), CeActivityDto.Status.FAILED, null, error);
 
     Optional<CeActivityDto> activityDto = dbTester.getDbClient().ceActivityDao().selectByUuid(session, task.getUuid());
-    Assertions.assertThat(activityDto).isPresent();
+    assertThat(activityDto).isPresent();
 
     assertThat(activityDto.get().getErrorMessage()).isEqualTo(error.getMessage());
     assertThat(activityDto.get().getErrorStacktrace()).isEqualToIgnoringWhitespace(stacktraceToString(error));
@@ -387,7 +386,7 @@ public class InternalCeQueueImplTest {
   @Test
   public void fail_to_cancel_if_in_progress() throws Exception {
     expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage(startsWith("Task is in progress and can't be canceled"));
+    expectedException.expectMessage(Matchers.startsWith("Task is in progress and can't be canceled"));
 
     CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
     underTest.peek(WORKER_UUID_2);
@@ -445,7 +444,7 @@ public class InternalCeQueueImplTest {
   }
 
   private void verifyCanceled(CeQueueDto original) {
-    Assertions.assertThat(dbTester.getDbClient().ceQueueDao().selectByUuid(dbTester.getSession(), original.getUuid())).isAbsent();
+    assertThat(dbTester.getDbClient().ceQueueDao().selectByUuid(dbTester.getSession(), original.getUuid())).isEmpty();
     CeActivityDto dto = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), original.getUuid()).get();
     assertThat(dto.getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
     assertThat(dto.getExecutionCount()).isEqualTo(original.getExecutionCount());
index 743f51e169dcad009ba4de2a747e88631d3684ae..0e038487294282dcb064f8effff4f019d3513475 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.ce.taskprocessor;
 
 import com.google.common.collect.ImmutableSet;
 import java.util.Set;
-import org.assertj.guava.api.Assertions;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -30,7 +29,6 @@ import org.sonar.ce.queue.CeTaskResult;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-
 public class CeTaskProcessorRepositoryImplTest {
   private static final String SOME_CE_TASK_TYPE = "some type";
   private static final String SOME_COMPONENT_KEY = "key";
@@ -73,7 +71,7 @@ public class CeTaskProcessorRepositoryImplTest {
   public void getForTask_returns_absent_if_repository_is_empty() {
     CeTaskProcessorRepositoryImpl underTest = new CeTaskProcessorRepositoryImpl(new CeTaskProcessor[] {});
 
-    Assertions.assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isAbsent();
+    assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isEmpty();
   }
 
   @Test
@@ -83,7 +81,7 @@ public class CeTaskProcessorRepositoryImplTest {
       createCeTaskProcessor(SOME_CE_TASK_TYPE + "_2", SOME_CE_TASK_TYPE + "_3"),
     });
 
-    Assertions.assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isAbsent();
+    assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).isEmpty();
   }
 
   @Test
index 7a07b5e8b8ed9ca0f67055f86dc9323c34edcf0f..c8bebfd5f52cb1898bd5345a9fbe4e8cbc71b8ef 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.ce.taskprocessor;
 
-import com.google.common.base.Optional;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.rules.ExternalResource;
 import org.sonar.ce.queue.CeTask;
@@ -57,7 +57,7 @@ public class CeTaskProcessorRepositoryRule extends ExternalResource implements C
   public Optional<CeTaskProcessor> getForCeTask(CeTask ceTask) {
     CeTaskProcessor taskProcessor = index.get(ceTask.getType());
     checkState(taskProcessor != null, "CeTaskProcessor was not set in rule for task %s", ceTask);
-    return taskProcessor instanceof NoCeTaskProcessor ? Optional.<CeTaskProcessor>absent() : Optional.of(taskProcessor);
+    return taskProcessor instanceof NoCeTaskProcessor ? Optional.empty() : Optional.of(taskProcessor);
   }
 
   private enum NoCeTaskProcessor implements CeTaskProcessor {
index b63a9e0daccf087a0535878a80f0cf0f9a93ac55..05c6112ff57bf5ca50d893946921b5861420e1eb 100644 (file)
@@ -19,8 +19,8 @@
  */
 package org.sonar.ce.taskprocessor;
 
-import com.google.common.base.Optional;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
@@ -59,7 +59,7 @@ public class CeWorkerCallableImplTest {
 
   @Test
   public void no_pending_tasks_in_queue() throws Exception {
-    when(queue.peek(UNKNOWN_WORKER_UUID)).thenReturn(Optional.<CeTask>absent());
+    when(queue.peek(UNKNOWN_WORKER_UUID)).thenReturn(Optional.empty());
 
     assertThat(underTest.call()).isFalse();
 
index 0e8f678fd65aaeaec35bc6ce6e1bb91b4a1c4530..3ba6ad52aae09cbf4dcede27f4d639525b191ab5 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.db.ce;
 
-import com.google.common.base.Optional;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import javax.annotation.Nullable;
 import org.sonar.api.utils.System2;
@@ -40,7 +40,7 @@ public class CeActivityDao implements Dao {
   }
 
   public Optional<CeActivityDto> selectByUuid(DbSession dbSession, String uuid) {
-    return Optional.fromNullable(mapper(dbSession).selectByUuid(uuid));
+    return Optional.ofNullable(mapper(dbSession).selectByUuid(uuid));
   }
 
   public void insert(DbSession dbSession, CeActivityDto dto) {
index 90714f6ebdf463557f158c9135c2535d2f5e1cec..589f2e200c1f87abe8dd45d1171f93ab001801b6 100644 (file)
@@ -19,8 +19,8 @@
  */
 package org.sonar.db.ce;
 
-import com.google.common.base.Optional;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.apache.ibatis.session.RowBounds;
 import org.sonar.api.utils.System2;
@@ -77,7 +77,7 @@ public class CeQueueDao implements Dao {
   }
 
   public Optional<CeQueueDto> selectByUuid(DbSession session, String uuid) {
-    return Optional.fromNullable(mapper(session).selectByUuid(uuid));
+    return Optional.ofNullable(mapper(session).selectByUuid(uuid));
   }
 
   public List<CeQueueDto> selectPendingByMinimumExecutionCount(DbSession dbSession, int minExecutionCount) {
@@ -117,7 +117,7 @@ public class CeQueueDao implements Dao {
   public Optional<CeQueueDto> peek(DbSession session, String workerUuid, int maxExecutionCount) {
     List<EligibleTaskDto> eligibles = mapper(session).selectEligibleForPeek(maxExecutionCount, ONE_RESULT_PAGINATION);
     if (eligibles.isEmpty()) {
-      return Optional.absent();
+      return Optional.empty();
     }
 
     EligibleTaskDto eligible = eligibles.get(0);
@@ -130,7 +130,7 @@ public class CeQueueDao implements Dao {
       new UpdateIf.NewProperties(IN_PROGRESS, workerUuid, eligible.getExecutionCount() + 1, now, now),
       new UpdateIf.OldProperties(PENDING, eligible.getExecutionCount()));
     if (touchedRows != 1) {
-      return Optional.absent();
+      return Optional.empty();
     }
 
     CeQueueDto result = mapper(session).selectByUuid(eligible.getUuid());
index 2bc2840a7c3df39f32572e53345703752527e018..f11864bb66bd0f583d17624823907c8498d2f7f7 100644 (file)
 package org.sonar.db.ce;
 
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.junit.Rule;
 import org.junit.Test;
@@ -58,7 +58,7 @@ public class CeActivityDaoTest {
     CeActivityDto inserted = insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS);
 
     Optional<CeActivityDto> saved = underTest.selectByUuid(db.getSession(), "TASK_1");
-    assertThat(saved.isPresent()).isTrue();
+    assertThat(saved).isPresent();
     CeActivityDto dto = saved.get();
     assertThat(dto.getUuid()).isEqualTo("TASK_1");
     assertThat(dto.getComponentUuid()).isEqualTo("PROJECT_1");
@@ -306,7 +306,7 @@ public class CeActivityDaoTest {
 
     underTest.deleteByUuids(db.getSession(), ImmutableSet.of("TASK_1", "TASK_3"));
     assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isFalse();
-    assertThat(underTest.selectByUuid(db.getSession(), "TASK_2").isPresent()).isTrue();
+    assertThat(underTest.selectByUuid(db.getSession(), "TASK_2")).isPresent();
     assertThat(underTest.selectByUuid(db.getSession(), "TASK_3").isPresent()).isFalse();
   }
 
@@ -317,7 +317,7 @@ public class CeActivityDaoTest {
     // must not fail
     underTest.deleteByUuids(db.getSession(), singleton("TASK_2"));
 
-    assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isTrue();
+    assertThat(underTest.selectByUuid(db.getSession(), "TASK_1")).isPresent();
   }
 
   @Test
index 1ff894d6d39cc0658db55f8ba673741f73da70f4..0bcc63c25218832d75bc912878b43ebd5cd03fff 100644 (file)
 package org.sonar.db.ce;
 
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Random;
 import java.util.stream.Stream;
 import javax.annotation.Nullable;
@@ -193,7 +193,7 @@ public class CeQueueDaoTest {
     insert(TASK_UUID_1, COMPONENT_UUID_1, PENDING);
 
     underTest.deleteByUuid(db.getSession(), "UNKNOWN");
-    assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1).isPresent()).isTrue();
+    assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isPresent();
 
     underTest.deleteByUuid(db.getSession(), TASK_UUID_1);
     assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1).isPresent()).isFalse();
@@ -276,7 +276,7 @@ public class CeQueueDaoTest {
 
     // peek first one
     Optional<CeQueueDto> peek = underTest.peek(db.getSession(), WORKER_UUID_1, MAX_EXECUTION_COUNT);
-    assertThat(peek.isPresent()).isTrue();
+    assertThat(peek).isPresent();
     assertThat(peek.get().getUuid()).isEqualTo(TASK_UUID_1);
     assertThat(peek.get().getStatus()).isEqualTo(IN_PROGRESS);
     assertThat(peek.get().getWorkerUuid()).isEqualTo(WORKER_UUID_1);
@@ -285,7 +285,7 @@ public class CeQueueDaoTest {
 
     // peek second one
     peek = underTest.peek(db.getSession(), WORKER_UUID_2, MAX_EXECUTION_COUNT);
-    assertThat(peek.isPresent()).isTrue();
+    assertThat(peek).isPresent();
     assertThat(peek.get().getUuid()).isEqualTo(TASK_UUID_2);
     assertThat(peek.get().getStatus()).isEqualTo(IN_PROGRESS);
     assertThat(peek.get().getWorkerUuid()).isEqualTo(WORKER_UUID_2);
@@ -304,7 +304,7 @@ public class CeQueueDaoTest {
     insert(TASK_UUID_2, COMPONENT_UUID_1, PENDING);
 
     Optional<CeQueueDto> peek = underTest.peek(db.getSession(), WORKER_UUID_1, MAX_EXECUTION_COUNT);
-    assertThat(peek.isPresent()).isTrue();
+    assertThat(peek).isPresent();
     assertThat(peek.get().getUuid()).isEqualTo(TASK_UUID_1);
     assertThat(peek.get().getWorkerUuid()).isEqualTo(WORKER_UUID_1);
     assertThat(peek.get().getExecutionCount()).isEqualTo(1);
index 9226758c2cd0d60f09b1e4881edd147e0bf72d29..4fcc448c83f9699acd6fcfc20d3c9e2b65649015 100644 (file)
 package org.sonar.ce.queue;
 
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.annotation.Nonnull;
@@ -99,7 +99,7 @@ public class CeQueueImpl implements CeQueue {
     if (dto.getComponentUuid() == null) {
       return new CeQueueDtoToCeTask(defaultOrganizationProvider.get().getUuid()).apply(dto);
     }
-    Optional<ComponentDto> componentDto = dbClient.componentDao().selectByUuid(dbSession, dto.getComponentUuid());
+    com.google.common.base.Optional<ComponentDto> componentDto = dbClient.componentDao().selectByUuid(dbSession, dto.getComponentUuid());
     if (componentDto.isPresent()) {
       return new CeQueueDtoToCeTask(defaultOrganizationProvider.get().getUuid(), ImmutableMap.of(dto.getComponentUuid(), componentDto.get())).apply(dto);
     }
index 8fb454385de64de9e6f22d1ffcdf49a82447bf69..777e51746ad5ca99cb4157ff7f861ed5115dd26e 100644 (file)
@@ -197,12 +197,12 @@ public class ActivityAction implements CeWsAction {
       return Optional.absent();
     }
 
-    Optional<CeQueueDto> queue = dbClient.ceQueueDao().selectByUuid(dbSession, textQuery);
+    java.util.Optional<CeQueueDto> queue = dbClient.ceQueueDao().selectByUuid(dbSession, textQuery);
     if (queue.isPresent()) {
       return Optional.of(formatter.formatQueue(dbSession, queue.get()));
     }
 
-    Optional<CeActivityDto> activity = dbClient.ceActivityDao().selectByUuid(dbSession, textQuery);
+    java.util.Optional<CeActivityDto> activity = dbClient.ceActivityDao().selectByUuid(dbSession, textQuery);
     if (activity.isPresent()) {
       return Optional.of(formatter.formatActivity(dbSession, activity.get()));
     }
index fdc082607ed623abc8ddb144364abe163d7c9bd7..a39958add89d93c7418aa21106c84eb4e26800c4 100644 (file)
  */
 package org.sonar.server.ce.ws;
 
-import com.google.common.base.Optional;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
@@ -92,12 +92,12 @@ public class TaskAction implements CeWsAction {
       WsCe.TaskResponse.Builder wsTaskResponse = WsCe.TaskResponse.newBuilder();
       Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, taskUuid);
       if (queueDto.isPresent()) {
-        Optional<ComponentDto> component = loadComponent(dbSession, queueDto.get().getComponentUuid());
+        com.google.common.base.Optional<ComponentDto> component = loadComponent(dbSession, queueDto.get().getComponentUuid());
         checkPermission(component);
         wsTaskResponse.setTask(wsTaskFormatter.formatQueue(dbSession, queueDto.get(), component));
       } else {
         CeActivityDto ceActivityDto = WsUtils.checkFoundWithOptional(dbClient.ceActivityDao().selectByUuid(dbSession, taskUuid), "No activity found for task '%s'", taskUuid);
-        Optional<ComponentDto> component = loadComponent(dbSession, ceActivityDto.getComponentUuid());
+        com.google.common.base.Optional<ComponentDto> component = loadComponent(dbSession, ceActivityDto.getComponentUuid());
         checkPermission(component);
         Set<AdditionalField> additionalFields = AdditionalField.getFromRequest(wsRequest);
         maskErrorStacktrace(ceActivityDto, additionalFields);
@@ -108,14 +108,14 @@ public class TaskAction implements CeWsAction {
     }
   }
 
-  private Optional<ComponentDto> loadComponent(DbSession dbSession, @Nullable String projectUuid) {
+  private com.google.common.base.Optional<ComponentDto> loadComponent(DbSession dbSession, @Nullable String projectUuid) {
     if (projectUuid == null) {
-      return Optional.absent();
+      return com.google.common.base.Optional.absent();
     }
     return dbClient.componentDao().selectByUuid(dbSession, projectUuid);
   }
 
-  private void checkPermission(Optional<ComponentDto> component) {
+  private void checkPermission(com.google.common.base.Optional<ComponentDto> component) {
     if (component.isPresent()) {
       String orgUuid = component.get().getOrganizationUuid();
       if (!userSession.hasPermission(OrganizationPermission.ADMINISTER, orgUuid) &&
index 6e2b2b7dc7adcf4f8db1b0a498a0cd6576c304c8..147e1764829f1c78a2b41e2880245e326c25df1a 100644 (file)
@@ -19,8 +19,8 @@
  */
 package org.sonar.ce.queue;
 
-import com.google.common.base.Optional;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;