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

Add cache for commit responses based on hashes #839

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

thomas-boehm-tractive
Copy link
Contributor

Commit information, identiefied by the has, does not change over time. Therefore, introduce a cache and add the information once it is retrieved first.

Your checklist for this pull request

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or in Jenkins JIRA
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Did you provide a test-case? That demonstrates feature works or fixes the issue.
    • No, as I am not sure how to write those.

Fixes #838

@@ -143,6 +143,7 @@ public class BitbucketCloudApiClient implements BitbucketApi {
private static final Cache<String, BitbucketTeam> cachedTeam = new Cache<>(6, HOURS);
private static final Cache<String, AvatarImage> cachedAvatar = new Cache<>(6, HOURS);
private static final Cache<String, List<BitbucketCloudRepository>> cachedRepositories = new Cache<>(3, HOURS);
private static final Cache<String, BitbucketCloudCommit> cachedCommits = new Cache<>(24, HOURS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit inconsistent that the maximum duration of cachedCommits is not configurable via BitbucketCloudEndpoint like teamCacheDuration and repositoriesCacheDuration; but I suppose it's okay because Bitbucket Cloud is expected to return the same information as in the immutable Git commit object. In particular, BitbucketCloudCommit does not include git notes.

@lifeofguenter
Copy link
Contributor

nice one @thomas-boehm-tractive !

thanks @KalleOlaviNiemitalo for having a look

@lifeofguenter lifeofguenter added the java Pull requests that update Java code label Mar 28, 2024
@lifeofguenter lifeofguenter merged commit 041fa69 into jenkinsci:master Mar 28, 2024
16 checks passed
} else {
return request.call();
}
} catch (Exception ex) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read right this catch eat any exception thrown by the callable. Before exception was log to the build console, now it is not logged and return null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think you might be right. Did you already create a new issue for this, as this PR is already merged?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I was here because I check changes in jenkins plugin before update in production.
Feel free to create an issue and a PR with a unit test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomas-boehm-tractive would you be able to create a PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomas-boehm-tractive any news about fix for this issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response, I didn't get to this in the last weeks.
Honestly, I am not really sure if this really is an issue, as similar blocks in this file behave exactly like this (see e.g. getTeam or getTeamAvatar function). My PR changed the behavior, but change it to behave like the code does on several other positions.
Are you convinced I should change this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'm sure, what is the reason to eat the exception and not inform the user that something was wrong?
I was on these changes of this pull request, I did see other places. Eventually we should fix also other code.
In short what should do the jenkins user if something happens and there is no apparently reason? I should replicate with jenkins in debug mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a ticket, and will create a PR within the next days:
#850

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created PR, I think this should bring back the behavior from before this PR was merged: #851

thomas-boehm-tractive added a commit to Tractive/bitbucket-branch-source-plugin that referenced this pull request May 23, 2024
Bug was introduced in jenkinsci#839, as discussed here jenkinsci#839 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature java Pull requests that update Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache commit information identified by hash
4 participants