-
Notifications
You must be signed in to change notification settings - Fork 349
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
Add cache for commit responses based on hashes #839
Conversation
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Show resolved
Hide resolved
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Show resolved
Hide resolved
@@ -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); |
There was a problem hiding this comment.
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
.
7f8b3c4
to
fda4056
Compare
nice one @thomas-boehm-tractive ! thanks @KalleOlaviNiemitalo for having a look |
} else { | ||
return request.call(); | ||
} | ||
} catch (Exception ex) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Bug was introduced in jenkinsci#839, as discussed here jenkinsci#839 (review)
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
Fixes #838