Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

381: Retry failed materialization of hosted repository storage #617

wants to merge 2 commits into from


Copy link

@rwestberg rwestberg commented May 4, 2020

Hi all,

Please review this change that improves the reliability of the initial materialization of hosted repository storage.

Best regards,


  • Change must not contain extraneous whitespace
  • Change must be properly reviewed


  • SKARA-381: Retry failed materialisation of HostedRepositoryStorage



$ git fetch pull/617/head:pull/617
$ git checkout pull/617

Copy link

@bridgekeeper bridgekeeper bot commented May 4, 2020

👋 Welcome back rwestberg! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request.

@openjdk openjdk bot added the rfr label May 4, 2020
Copy link

@mlbridge mlbridge bot commented May 4, 2020


Copy link

@JornVernee JornVernee left a comment

Had to look at this a bit since the control flow is a bit confusing with the early return from the constructor. How about putting the retry logic into a separate helper method? This is what I came up with:

HostedRepositoryStorage(HostedRepository repository, Path localStorage, String ref, String fileName, String authorName, String authorEmail, String message, StorageSerializer<T> serializer, StorageDeserializer<T> deserializer) {
    this.hostedRepository = repository;
    this.ref = ref;
    this.fileName = fileName;
    this.authorEmail = authorEmail;
    this.authorName = authorName;
    this.message = message;
    this.serializer = serializer;
    this.deserializer = deserializer;

    this.localRepository = tryMaterialize(repository, localStorage, ref, fileName, authorName, authorEmail, message);
    repositoryStorage = new RepositoryStorage<>(localRepository, fileName, authorName, authorEmail, message, serializer, deserializer);
    current = current();

private static Repository tryMaterialize(HostedRepository repository, Path localStorage, String ref, String fileName, String authorName, String authorEmail, String message) {
    int retryCount = 0;
    IOException lastException = null;

    while (retryCount < 10) {
        try {
            try {
                return Repository.materialize(localStorage, repository.url(), "+" + ref + ":storage");
            } catch (IOException ignored) {
                // The remote ref may not yet exist
                Repository localRepository = Repository.init(localStorage, repository.repositoryType());
                var storage = Files.writeString(localStorage.resolve(fileName), "");
                var firstCommit = localRepository.commit(message, authorName, authorEmail);

                // If the materialization failed for any other reason than the remote ref not existing, this will fail
                localRepository.push(firstCommit, repository.url(), ref);
                return localRepository;
        } catch (IOException e) {
            lastException = e;
    throw new UncheckedIOException("Retry count exceeded", lastException);

This would also allow keeping localRepository as a final field. What do you think?

Copy link

@openjdk openjdk bot commented May 7, 2020

@rwestberg This change now passes all automated pre-integration checks. When the change also fulfills all project specific requirements, type /integrate in a new comment to proceed. After integration, the commit message will be:

381: Retry failed materialization of hosted repository storage

Reviewed-by: jvernee
  • If you would like to add a summary, use the /summary command.
  • To credit additional contributors, use the /contributor command.
  • To add additional solved issues, use the /solves command.

Since the source branch of this PR was last updated there has been 1 commit pushed to the master branch:

  • c967e0a: 384: Suggest issue command instead of solves command

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge master into your branch, and then specify the current head hash when integrating, like this: /integrate c967e0a71d856482ce1750baff163a30c2210334.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label May 7, 2020
Copy link
Member Author

@rwestberg rwestberg commented May 8, 2020

Thanks for reviewing! I agree, your suggestion looks nicer, I'll apply it and push.

Copy link
Member Author

@rwestberg rwestberg commented May 8, 2020


@openjdk openjdk bot closed this May 8, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels May 8, 2020
Copy link

@openjdk openjdk bot commented May 8, 2020

@rwestberg The following commits have been pushed to master since your change was applied:

  • c967e0a: 384: Suggest issue command instead of solves command

Your commit was automatically rebased without conflicts.

Pushed as commit eb9b6b1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants