Merge branch 'stable-3.1' into stable-3.2 * stable-3.1: FetchAction: Fix FloggerFormatString pattern flagged by error prone Add replication delay for asynchronous fetch calls Trigger indexing only for local ref updates Index change only for meta ref propagation Allow asynchronous fetch calls Comment the LocalDiskRepositoryManager in ApplyObject Fix issue with reading maxApiPayloadSize property Change-Id: I191ae7b1450d50db567ada26fcc19a7b8752d1ef
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 ea2ce32..20d9aba 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
@@ -30,6 +30,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; @@ -290,10 +291,10 @@ 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) { repLog.warn( "NOT scheduling replication {}:{} because could not open source project", project, @@ -301,25 +302,21 @@ e); return false; } - if (projectState == null) { + if (!projectState.isPresent()) { repLog.warn( "NOT scheduling replication {}:{} because project does not exist", project, ref); throw new NoSuchProjectException(project); } - if (!projectState.statePermitsRead()) { + if (!projectState.get().statePermitsRead()) { repLog.warn( "NOT scheduling replication {}:{} because project is not readable", project, ref); return false; } - if (!shouldReplicate(projectState, userProvider.get())) { - repLog.warn( - "NOT scheduling replication {}:{} because project is supposed to be replicated", - project, - ref); + if (!shouldReplicate(projectState.get(), userProvider.get())) { return false; } if (FetchOne.ALL_REFS.equals(ref)) { @@ -361,16 +358,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/ApplyObjectAction.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectAction.java index 77c54fa..f029834 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectAction.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectAction.java
@@ -78,7 +78,7 @@ } catch (MissingParentObjectException e) { throw new ResourceConflictException(e.getMessage(), e); } catch (NumberFormatException | IOException e) { - throw new RestApiException(e.getMessage(), e); + throw RestApiException.wrap(e.getMessage(), e); } catch (RefUpdateException e) { throw new UnprocessableEntityException(e.getMessage()); }
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 a6fd8ec..2767f1d 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()); }