From 294fddc2b0043482018a3b6ebbcf0d3abe7aef90 Mon Sep 17 00:00:00 2001 From: ju Date: Sat, 29 Sep 2018 19:27:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=94=B9?= =?UTF-8?q?=E4=B8=80=E9=83=A8=E5=88=86findbugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/remote/ui/UserManagerPane.java | 4 +- .../manager/impl/RecentSearchManager.java | 40 ++++++------------- .../mainframe/socketio/DesignerSocketIO.java | 2 +- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java index 1e22dc808..8b8688e99 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java @@ -58,7 +58,7 @@ public class UserManagerPane extends BasicPane { /** * 每页个数 */ - private final int DEFAULT_NUM_EACH_PAGE = 50; + private static final int DEFAULT_NUM_EACH_PAGE = 50; /** * 获取的决策平台成员 @@ -171,7 +171,7 @@ public class UserManagerPane extends BasicPane { /** * 搜索关键词变更监听 */ - private DocumentListener documentListener = new DocumentListener() { + private transient DocumentListener documentListener = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { keyWord = keyField.getText(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index 866c2c734..0b48d7cf9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -45,9 +45,10 @@ import java.util.List; */ public class RecentSearchManager implements AlphaFineSearchProvider { private static final int MAX_SIZE = 100; - private static volatile RecentSearchManager instance; - IndexReader indexReader = null; - IndexSearcher indexSearcher = null; + + private static final RecentSearchManager INSTANCE = new RecentSearchManager(); + + private IndexReader indexReader = null; //索引存储路径 private String path = ProductConstants.getEnvHome() + File.separator + "searchIndex"; //分词器,暂时先用这个 @@ -57,25 +58,18 @@ public class RecentSearchManager implements AlphaFineSearchProvider { private IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer); private IndexWriter indexWriter = null; private SearchResult recentModelList; - private SearchResult modelList; - + public static RecentSearchManager getInstance() { - if (instance == null) { - synchronized (RecentSearchManager.class) { - if (instance == null) { - instance = new RecentSearchManager(); - instance.initWriter(); - } - } - } - return instance; + + return INSTANCE; } @Override public SearchResult getLessSearchResult(String[] searchText) { - this.modelList = new SearchResult(); - for (int j = 0; j < searchText.length; j++) { - recentModelList = getRecentModelList(searchText[j]); + + SearchResult modelList = new SearchResult(); + for (String aSearchText : searchText) { + recentModelList = getRecentModelList(aSearchText); } if (recentModelList != null && recentModelList.size() > 0) { modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Latest"))); @@ -92,8 +86,8 @@ public class RecentSearchManager implements AlphaFineSearchProvider { public SearchResult getMoreSearchResult(String searchText) { return new SearchResult(); } - - public synchronized SearchResult getRecentModelList(String searchText) { + + private synchronized SearchResult getRecentModelList(String searchText) { return searchBySort(searchText); } @@ -121,7 +115,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider { try { indexWriter.close(); indexReader = DirectoryReader.open(directory); - indexSearcher = new IndexSearcher(indexReader); } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -130,8 +123,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider { /** * 添加模型 * - * @param searchKey - * @param cellModel */ public void addModel(String searchKey, AlphaCellModel cellModel) { if(cellModel == null){ @@ -151,8 +142,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider { /** * 写文档,建立索引 - * - * @param doc */ private void writeDoc(Document doc) { try { @@ -166,9 +155,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider { /** * 按序搜索 - * - * @param key - * @return */ private synchronized SearchResult searchBySort(String key) { recentModelList = new SearchResult(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 3c04dff35..132d72d17 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -38,7 +38,7 @@ public class DesignerSocketIO { } private static Optional socketIO = Optional.absent(); - public static Status status = Status.Disconnected; + private static Status status = Status.Disconnected; private static final Emitter.Listener printLog = new Emitter.Listener() { @Override