Merge branch 'stable-3.1' * stable-3.1: Jenkinsfile: use gerrit-ci-library pipeline for plugin validation Mute logging for missing fetch param in remote section Fix NPE issue from pull replication after configuration auto reload Make HTTP connection parameters source-aware Fix issue with auto reload of sources Add 'Pull Replication' capability Adopt new replication configuration structure Change-Id: I5d1cfdba092afc8ba7abd2f52561f1ee575fdd90
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java index 13b1466..3a4d4a7 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -29,6 +29,7 @@ import com.google.gerrit.entities.BranchNameKey; import com.google.gerrit.entities.Project; import com.google.gerrit.entities.RefNames; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.config.FactoryModule; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.restapi.AuthException; @@ -277,19 +278,19 @@ new Callable<Boolean>() { @Override public Boolean call() throws NoSuchProjectException, PermissionBackendException { - ProjectState projectState; + Optional<ProjectState> projectState; try { - projectState = projectCache.checkedGet(project); - } catch (IOException e) { + projectState = projectCache.get(project); + } catch (StorageException e) { return false; } - if (projectState == null) { + if (!projectState.isPresent()) { throw new NoSuchProjectException(project); } - if (!projectState.statePermitsRead()) { + if (!projectState.get().statePermitsRead()) { return false; } - if (!shouldReplicate(projectState, userProvider.get())) { + if (!shouldReplicate(projectState.get(), userProvider.get())) { return false; } if (FetchOne.ALL_REFS.equals(ref)) { @@ -324,16 +325,16 @@ new Callable<Boolean>() { @Override public Boolean call() throws NoSuchProjectException, PermissionBackendException { - ProjectState projectState; + Optional<ProjectState> projectState; try { - projectState = projectCache.checkedGet(project); - } catch (IOException e) { + projectState = projectCache.get(project); + } catch (StorageException e) { return false; } - if (projectState == null) { + if (!projectState.isPresent()) { throw new NoSuchProjectException(project); } - return shouldReplicate(projectState, userProvider.get()); + return shouldReplicate(projectState.get(), userProvider.get()); } }) .call();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java index 6970299..c44bcbc 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java
@@ -84,7 +84,7 @@ | ExecutionException | IllegalStateException | TimeoutException e) { - throw new RestApiException(e.getMessage(), e); + throw RestApiException.wrap(e.getMessage(), e); } catch (RemoteConfigurationMissingException e) { throw new UnprocessableEntityException(e.getMessage()); }