Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.1.1
* Improve performance by using `ConcurrentReferenceHashMap` instead of `synchronized`

# 1.1.0
* Update PMD to 7.24.0
* Dropped support for IntelliJ IDEA < 261 to fix deprecations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.nio.ByteBuffer;
import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
Expand All @@ -25,7 +24,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import software.xdev.pmd.external.org.apache.shiro.lang.util.SoftHashMap;
import software.xdev.pmd.external.org.springframework.util.ConcurrentReferenceHashMap;


/**
Expand All @@ -37,9 +36,7 @@
public class ZipFileFingerprinter implements ClasspathEntryFingerprinter
{
// IMPROVED
private static final Map<String, UrlCachedPayload> FILE_CRC_CHECKSUMS_CACHE =
Collections.synchronizedMap(new SoftHashMap<>());

private static final Map<String, UrlCachedPayload> FILE_CRC_CHECKSUMS_CACHE = new ConcurrentReferenceHashMap<>();

record UrlCachedPayload(
long length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
package net.sourceforge.pmd.lang.rule.xpath.internal;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;

import org.apache.commons.lang3.exception.ContextedRuntimeException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -45,6 +43,7 @@
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.util.DataMap;
import net.sourceforge.pmd.util.DataMap.SimpleDataKey;
import software.xdev.pmd.external.org.springframework.util.ConcurrentReferenceHashMap;


/**
Expand All @@ -57,8 +56,8 @@ public class SaxonXPathRuleQuery
{
// IMPROVED
// Different XPathHandlers have different extensions (e.g. pmd-java) that are registered with configuration
private static Map<XPathHandler, CachedInitData> cachedInitData = Collections.synchronizedMap(new WeakHashMap<>());

private static Map<XPathHandler, CachedInitData> cachedInitData = new ConcurrentReferenceHashMap<>(
ConcurrentReferenceHashMap.ReferenceType.WEAK);

record CachedInitData(
Configuration configuration,
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/software/xdev/pmd/analysis/PMDAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -46,7 +45,7 @@
import net.sourceforge.pmd.reporting.Report;
import software.xdev.pmd.config.PluginConfiguration;
import software.xdev.pmd.config.PluginConfigurationManager;
import software.xdev.pmd.external.org.apache.shiro.lang.util.SoftHashMap;
import software.xdev.pmd.external.org.springframework.util.ConcurrentReferenceHashMap;
import software.xdev.pmd.langversion.ManagedLanguageVersionResolver;
import software.xdev.pmd.model.config.ConfigurationLocation;

Expand All @@ -61,11 +60,11 @@ public class PMDAnalyzer implements Disposable

private final Project project;

private final Map<Optional<Module>, ReentrantLock> locks = Collections.synchronizedMap(new HashMap<>());
private final Map<Optional<Module>, CacheFile> cacheFiles = Collections.synchronizedMap(new HashMap<>());
private final Map<Optional<Module>, ReentrantLock> locks = new ConcurrentHashMap<>();
private final Map<Optional<Module>, CacheFile> cacheFiles = new ConcurrentHashMap<>();
// Reuse classloader when path is the same
private final Map<Set<String>, ClassLoader> cachedSdkLibAuxClassLoader =
Collections.synchronizedMap(new SoftHashMap<>());
new ConcurrentReferenceHashMap<>();

public PMDAnalyzer(final Project project)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -40,7 +40,7 @@ public class CurrentFileAnalysisManager implements FileEditorManagerListener, Di
@NotNull
private final AtomicReference<PsiFile> currentlySelectedFile = new AtomicReference<>();
private final Map<PsiFile, Map<ExternalAnnotator<?, ?>, PMDAnalysisResult>> fileAnalysisResults =
Collections.synchronizedMap(new HashMap<>());
new ConcurrentHashMap<>();

public CurrentFileAnalysisManager(@NotNull final Project project)
{
Expand Down
Loading