Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4945: JavadocPackageCheck should be thread-safe #4946

Merged
merged 1 commit into from Aug 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,8 +20,8 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc;

import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
import com.puppycrawl.tools.checkstyle.api.FileText;
Expand All @@ -46,7 +46,7 @@ public class JavadocPackageCheck extends AbstractFileSetCheck {
public static final String MSG_PACKAGE_INFO = "javadoc.packageInfo";

/** The directories checked. */
private final Set<File> directoriesChecked = new HashSet<>();
private final Set<File> directoriesChecked = ConcurrentHashMap.newKeySet();

/** Indicates if allow legacy "package.html" file to be used. */
private boolean allowLegacy;
Expand All @@ -70,9 +70,8 @@ public void beginProcessing(String charset) {
protected void processFiltered(File file, FileText fileText) {
// Check if already processed directory
final File dir = file.getParentFile();
if (!directoriesChecked.contains(dir)) {
directoriesChecked.add(dir);

final boolean isDirChecked = !directoriesChecked.add(dir);
if (!isDirChecked) {
// Check for the preferred file.
final File packageInfo = new File(dir, "package-info.java");
final File packageHtml = new File(dir, "package.html");
Expand Down