Skip to content

Commit

Permalink
Issue checkstyle#4945: JavadocPackageCheck should be thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
soon committed Aug 14, 2017
1 parent 78de3dc commit 3b47224
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
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

0 comments on commit 3b47224

Please sign in to comment.