Skip to content

Commit

Permalink
Remove internal IssueTrackerType.rpc_cache attribute. Fixes #3757
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Nov 6, 2024
1 parent 9ea797e commit 32ace44
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions tcms/issuetracker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class IssueTrackerType:
supports!
"""

rpc_cache = {}

def __init__(self, bug_system, request):
"""
:bug_system: - BugSystem object
Expand Down Expand Up @@ -229,23 +227,14 @@ def _rpc_connection(self):
def rpc(self):
"""
Returns an object which is used to communicate to the external system.
This property is meant to be used by the rest of the integration code
and provides caching b/c connecting to a remote system may be a slow
operation.
This property is meant to be used by the rest of the integration code.
"""
# b/c jira.JIRA tries to connect when object is created
# see https://github.com/kiwitcms/Kiwi/issues/100
if self.is_adding_testcase_to_issue_disabled():
return None

# NOTE: using a tuple as the cache-key to prevent integrations which define
# personal ApiTokens to accidentally use a cached version
# for the same URL but different credentials
rpc_key = (self.bug_system.base_url, getattr(self.request, "user", None))
if rpc_key not in self.rpc_cache:
self.rpc_cache[rpc_key] = self._rpc_connection()

return self.rpc_cache[rpc_key]
return self._rpc_connection()

@property
def rpc_credentials(self):
Expand Down

0 comments on commit 32ace44

Please sign in to comment.