Skip to content

Conversation

tulinkry
Copy link
Contributor

@tulinkry tulinkry commented May 2, 2017

  • avoiding concurrent modification exception (when the list is modified later)

This piece of code in repos.jsp produces an CME when modifying the list of repositories (which is taken directly from the RE). Returning a copy solves the problem, the objects in the list are not modified.

List<RepositoryInfo> repos = pHelper.getRepositoryInfo(project);
String projDesc = project.getName();
Integer cnt = 0;
Collections.sort(repos, comparatorRepo); <!-- HERE -->
%>
<%
for (RepositoryInfo ri : repos) {
    if (cnt > 0 && ri.getParent() == null)
        // discard repositories without a parent url
        continue;
    if (cnt != 0) {
        projDesc = ri.getDirectoryName()
                     .replace(cfg.getSourceRootPath() + File.separator, "");
    }
    %>

 - avoiding concurrent modification exception (when the list is modified later)
@tulinkry tulinkry added this to the 1.1 milestone May 2, 2017
@tulinkry tulinkry self-assigned this May 2, 2017
*/
public List<RepositoryInfo> getRepositoryInfo(Project p) {
if (!cfg.isAllowed(p)) {
return new ArrayList<>();
}
Map<Project, List<RepositoryInfo>> map = cfg.getEnv().getProjectRepositoriesMap();
List<RepositoryInfo> info = map.get(p);
return info == null ? new ArrayList<>() : info;
return info == null ? new ArrayList<>() : new ArrayList<>(info);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add a comment explaining why this is done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@vladak vladak merged commit d0b8e91 into oracle:master May 3, 2017
@tulinkry tulinkry deleted the project-helper-fix branch May 3, 2017 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants