Skip to content

Commit 15dc416

Browse files
Add project key to cache key (#837)
If a requests is sent with a project key, and the key is not part of the cache key, following requests for other projects will result in the cached repositories for the first project, leading to wrong results
1 parent b26cce5 commit 15dc416

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,17 @@ public List<BitbucketCloudRepository> getRepositories(@CheckForNull UserRoleInRe
787787
.set("pagelen", MAX_PAGE_LENGTH);
788788
if (StringUtils.isNotBlank(projectKey)) {
789789
template.set("q", "project.key=" + "\"" + projectKey + "\""); // q=project.key="<projectKey>"
790+
cacheKey.append("::").append(projectKey);
791+
} else {
792+
cacheKey.append("::<undefined>");
790793
}
791794
if (role != null && authenticator != null) {
792795
template.set("role", role.getId());
793796
cacheKey.append("::").append(role.getId());
797+
} else {
798+
cacheKey.append("::<undefined>");
794799
}
800+
795801
Callable<List<BitbucketCloudRepository>> request = () -> {
796802
List<BitbucketCloudRepository> repositories = new ArrayList<>();
797803
Integer pageNumber = 1;

0 commit comments

Comments
 (0)