Browse Source

REPORT-98466 FileNodeConstants中使用List存储文件类型可能导致重复

newui
obo 1 year ago
parent
commit
3f3bd4376b
  1. 11
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

11
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

@ -11,9 +11,8 @@ import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.ExtraReportClassManager; import com.fr.report.ExtraReportClassManager;
import com.fr.report.fun.ReportSupportedFileProvider; import com.fr.report.fun.ReportSupportedFileProvider;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -23,7 +22,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/ */
public class FileNodeConstants { public class FileNodeConstants {
private static List<String> supportFileType; private static Set<String> supportFileType;
private static ReadWriteLock rwl = new ReentrantReadWriteLock(); private static ReadWriteLock rwl = new ReentrantReadWriteLock();
private FileNodeConstants() { private FileNodeConstants() {
@ -47,16 +46,14 @@ public class FileNodeConstants {
private static void addAppExtensions(FileExtension[] extensions) { private static void addAppExtensions(FileExtension[] extensions) {
for (int i = 0, size = extensions.length; i < size; i++) { for (int i = 0, size = extensions.length; i < size; i++) {
if (!supportFileType.contains(extensions[i].getExtension())) { supportFileType.add(extensions[i].getExtension());
supportFileType.add(extensions[i].getExtension());
}
} }
} }
private static void initSupportedTypes() { private static void initSupportedTypes() {
try { try {
rwl.writeLock().lock(); rwl.writeLock().lock();
supportFileType = new ArrayList<String>(); supportFileType = new LinkedHashSet<>();
//通过插件扩展的 //通过插件扩展的
Set<ReportSupportedFileProvider> providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG); Set<ReportSupportedFileProvider> providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG);
for (ReportSupportedFileProvider provider : providers) { for (ReportSupportedFileProvider provider : providers) {

Loading…
Cancel
Save