Skip to content

Commit dfaad4d

Browse files
committed
Add synchronized
1 parent 0d1c9a4 commit dfaad4d

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/main/java/com/junichi11/netbeans/modules/github/issues/GitHubCache.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,18 @@ public final class GitHubCache {
7878

7979
// @GuardedBy("this")
8080
private static final Map<String, GitHubCache> CACHES = Collections.synchronizedMap(new HashMap<String, GitHubCache>());
81+
// @GuardedBy("this")
8182
private List<User> collaborators;
83+
// @GuardedBy("this")
8284
private List<Milestone> milestones;
85+
// @GuardedBy("this")
8386
private List<Label> labels;
8487
// @GuardedBy("this")
8588
private List<RepositoryBranch> branches;
8689
// @GuardedBy("this")
8790
private List<Repository> forks;
8891
private User myself;
92+
// @GuardedBy("this")
8993
private final Map<String, Icon> userIcons = new HashMap<>();
9094
private final GitHubRepository repository;
9195
private static final Logger LOGGER = Logger.getLogger(GitHubCache.class.getName());
@@ -127,7 +131,7 @@ public synchronized void clear(GitHubRepository repository) {
127131
*
128132
* @return collaborators
129133
*/
130-
public List<User> getCollaborators() {
134+
public synchronized List<User> getCollaborators() {
131135
if (collaborators == null) {
132136
Repository ghRepository = repository.getRepository();
133137
GitHubClient client = repository.createGitHubClient();
@@ -160,7 +164,7 @@ public List<Milestone> getMilestones() {
160164
* {@code false}
161165
* @return milestones
162166
*/
163-
public List<Milestone> getMilestones(boolean force) {
167+
public synchronized List<Milestone> getMilestones(boolean force) {
164168
if (milestones == null || force) {
165169
if (milestones != null) {
166170
milestones.clear();
@@ -195,7 +199,7 @@ public List<Label> getLabels() {
195199
* @param force {@code true} if reload labels, otherwise {@code false}
196200
* @return labels
197201
*/
198-
public List<Label> getLabels(boolean force) {
202+
public synchronized List<Label> getLabels(boolean force) {
199203
if (labels == null || force) {
200204
if (labels != null) {
201205
labels.clear();
@@ -220,7 +224,8 @@ public List<Label> getLabels(boolean force) {
220224
*
221225
* @return myself
222226
*/
223-
public User getMySelf() {
227+
@CheckForNull
228+
public synchronized User getMySelf() {
224229
if (myself == null) {
225230
GitHubClient client = repository.createGitHubClient();
226231
if (client == null) {
@@ -243,7 +248,7 @@ public User getMySelf() {
243248
* @return user icon if it was got, otherwise {@code null}
244249
*/
245250
@CheckForNull
246-
public Icon getUserIcon(User user) {
251+
public synchronized Icon getUserIcon(User user) {
247252
if (user == null) {
248253
return null;
249254
}
@@ -361,5 +366,4 @@ public static synchronized User getUser(String oAuthToken) {
361366
}
362367
return user;
363368
}
364-
365369
}

0 commit comments

Comments
 (0)