Skip to content

Commit d0b8e91

Browse files
tulinkryVladimir Kotal
authored andcommitted
returning copy of the repository list (#1566)
1 parent 600ba64 commit d0b8e91

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/org/opensolaris/opengrok/web/ProjectHelper.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,21 @@ public static ProjectHelper getInstance(PageConfig cfg) {
104104
}
105105

106106
/**
107-
* Get repository info for particular project
107+
* Get repository info list for particular project. A copy of the list is
108+
* returned always to allow concurrent modifications of the list in the
109+
* caller. The items in the list shall not be modified concurrently, though.
108110
*
109-
* @param p Project
110-
* @return List of repository info or empty List if no info is found
111+
* @param p the project for which we find the repository info list
112+
* @return Copy of a list of repository info or empty list if no info is
113+
* found
111114
*/
112115
public List<RepositoryInfo> getRepositoryInfo(Project p) {
113116
if (!cfg.isAllowed(p)) {
114117
return new ArrayList<>();
115118
}
116119
Map<Project, List<RepositoryInfo>> map = cfg.getEnv().getProjectRepositoriesMap();
117120
List<RepositoryInfo> info = map.get(p);
118-
return info == null ? new ArrayList<>() : info;
121+
return info == null ? new ArrayList<>() : new ArrayList<>(info);
119122
}
120123

121124
/**
@@ -249,7 +252,7 @@ public Set<Project> getProjects(Group g) {
249252
}
250253
return cacheProjects(PROJECT_HELPER_GROUPED_PROJECT_GROUP + g.getName().toLowerCase(), g.getProjects());
251254
}
252-
255+
253256
/**
254257
* @param g group
255258
* @return filtered group's repositories
@@ -421,7 +424,7 @@ public boolean test(Project t) {
421424
cfg.setRequestAttribute(PROJECT_HELPER_FAVOURITE_GROUP, p);
422425
return val;
423426
}
424-
427+
425428
/**
426429
* Checks if the project is a favourite project
427430
*

0 commit comments

Comments
 (0)