Browse Source

无jira sonar修复

research/10.0
Hades 5 years ago
parent
commit
3b54e72008
  1. 13
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 7
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  3. 9
      designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java
  4. 7
      designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java
  5. 8
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  6. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  7. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  8. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  9. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java

13
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -41,17 +41,12 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList; private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate; private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache instacne;
public static HistoryTemplateListCache getInstance() { public static HistoryTemplateListCache getInstance() {
if (instacne == null) { return Holder.INSTANCE;
synchronized (HistoryTemplateListCache.class) {
if (instacne == null) {
instacne = new HistoryTemplateListCache();
}
} }
}
return instacne; private static class Holder {
private static final HistoryTemplateListCache INSTANCE = new HistoryTemplateListCache();
} }
private HistoryTemplateListCache() { private HistoryTemplateListCache() {

7
designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java

@ -80,10 +80,10 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
int total = connection.getContentLength(); int total = connection.getContentLength();
item.setTotalLength(total); item.setTotalLength(total);
InputStream reader = connection.getInputStream();
File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName())); File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName()));
StableUtils.makesureFileExist(tempFile); StableUtils.makesureFileExist(tempFile);
FileOutputStream writer = new FileOutputStream(tempFile); try ( InputStream reader = connection.getInputStream();
FileOutputStream writer = new FileOutputStream(tempFile)) {
byte[] buffer = new byte[UpdateConstants.BYTE]; byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0; int bytesRead = 0;
int totalBytesRead = 0; int totalBytesRead = 0;
@ -94,8 +94,7 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
item.setDownloadLength(totalBytesRead); item.setDownloadLength(totalBytesRead);
publish(item); publish(item);
} }
reader.close(); }
writer.close();
} }
/** /**

9
designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java

@ -82,15 +82,12 @@ public class DirectoryOperationFactory {
} }
private static void copy(String path1, String path2) throws IOException { private static void copy(String path1, String path2) throws IOException {
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1))); try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1)));
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2))); DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)))) {
byte[] date = new byte[in.available()]; byte[] date = new byte[in.available()];
in.read(date); in.read(date);
out.write(date); out.write(date);
}
in.close();
out.close();
} }
/** /**

7
designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java

@ -75,11 +75,8 @@ class BytesEncodingDetect extends Encoding {
* type. The encoding type with the highest probability is returned. * type. The encoding type with the highest probability is returned.
*/ */
public int detectEncoding(File testfile) { public int detectEncoding(File testfile) {
FileInputStream chinesefile; byte[] rawtext = new byte[(int) testfile.length()];
byte[] rawtext; try(FileInputStream chinesefile = new FileInputStream(testfile)) {
rawtext = new byte[(int) testfile.length()];
try {
chinesefile = new FileInputStream(testfile);
chinesefile.read(rawtext); chinesefile.read(rawtext);
chinesefile.close(); chinesefile.close();
} catch (Exception e) { } catch (Exception e) {

8
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -468,10 +468,9 @@ public class UpdateMainDialog extends UIDialog {
return; return;
} }
if (cacheFile.exists()) { if (cacheFile.exists()) {
InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8"); try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
BufferedReader br = new BufferedReader(streamReader); BufferedReader br = new BufferedReader(streamReader)) {
String readStr, updateTimeStr; String readStr, updateTimeStr;
while ((readStr = br.readLine()) != null) { while ((readStr = br.readLine()) != null) {
String[] updateInfo = readStr.split("\\t"); String[] updateInfo = readStr.split("\\t");
if (updateInfo.length == 2) { if (updateInfo.length == 2) {
@ -490,8 +489,7 @@ public class UpdateMainDialog extends UIDialog {
} }
} }
} }
br.close(); }
streamReader.close();
} }
} }

17
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -27,21 +27,20 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public class PluginSearchManager implements AlphaFineSearchProvider { public class PluginSearchManager implements AlphaFineSearchProvider {
private static volatile PluginSearchManager instance;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;
private PluginSearchManager() {
public static PluginSearchManager getInstance() {
if (instance == null) {
synchronized (PluginSearchManager.class) {
if (instance == null) {
instance = new PluginSearchManager();
}
} }
public static PluginSearchManager getInstance() {
return Holder.INSTANCE;
} }
return instance;
private static class Holder {
private static final PluginSearchManager INSTANCE = new PluginSearchManager();
} }
private static boolean isCompatibleCurrentEnv(String envVersion) { private static boolean isCompatibleCurrentEnv(String envVersion) {
@ -105,7 +104,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")));
return lessModelList; return lessModelList;
} }
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if(noConnectList != null){ if(noConnectList != null){
return noConnectList; return noConnectList;
} }

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -25,22 +25,22 @@ import java.util.List;
* Created by XiaXiang on 2017/3/31. * Created by XiaXiang on 2017/3/31.
*/ */
public class RecommendSearchManager implements AlphaFineSearchProvider { public class RecommendSearchManager implements AlphaFineSearchProvider {
private static volatile RecommendSearchManager instance;
private SearchResult modelList = new SearchResult(); private SearchResult modelList = new SearchResult();
private SearchResult recommendModelList = new SearchResult(); private SearchResult recommendModelList = new SearchResult();
private SearchResult complementAdviceModelList; private SearchResult complementAdviceModelList;
private SearchResult moreModelList = new SearchResult(); private SearchResult moreModelList = new SearchResult();
public static RecommendSearchManager getInstance() { private RecommendSearchManager() {
if (instance == null) {
synchronized (RecentSearchManager.class) {
if (instance == null) {
instance = new RecommendSearchManager();
}
} }
public static RecommendSearchManager getInstance() {
return Holder.INSTANCE;
} }
return instance;
private static class Holder {
private static final RecommendSearchManager INSTANCE = new RecommendSearchManager();
} }
@Override @Override
@ -51,7 +51,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) { if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult(); return new SearchResult();
} }
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if (noConnectList != null) { if (noConnectList != null) {
return noConnectList; return noConnectList;
} }

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java

@ -13,18 +13,18 @@ import java.util.regex.Pattern;
* Created by alex.sung on 2018/8/3. * Created by alex.sung on 2018/8/3.
*/ */
public class SegmentationManager { public class SegmentationManager {
private static volatile SegmentationManager segmentationManager = null;
private static final int MAX_CHINESE_CHARACTERS_NUM = 4; private static final int MAX_CHINESE_CHARACTERS_NUM = 4;
public static SegmentationManager getInstance() { private SegmentationManager() {
if (segmentationManager == null) {
synchronized (SegmentationManager.class) {
if (segmentationManager == null) {
segmentationManager = new SegmentationManager();
}
} }
public static SegmentationManager getInstance() {
return Holder.INSTANCE;
} }
return segmentationManager;
private static class Holder {
private static final SegmentationManager INSTANCE = new SegmentationManager();
} }
/** /**

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java

@ -18,19 +18,19 @@ import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
* Created by alex.sung on 2018/8/3. * Created by alex.sung on 2018/8/3.
*/ */
public class SimilarSearchManager implements AlphaFineSearchProvider { public class SimilarSearchManager implements AlphaFineSearchProvider {
private static volatile SimilarSearchManager instance;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList = new SearchResult(); private SearchResult moreModelList = new SearchResult();
public static SimilarSearchManager getInstance() { private SimilarSearchManager() {
if (instance == null) {
synchronized (SimilarSearchManager.class) {
if (instance == null) {
instance = new SimilarSearchManager();
}
} }
public static SimilarSearchManager getInstance() {
return Holder.INSTANCE;
} }
return instance;
private static class Holder {
private static final SimilarSearchManager INSTANCE = new SimilarSearchManager();
} }
@Override @Override
@ -40,7 +40,7 @@ public class SimilarSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) { if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult(); return new SearchResult();
} }
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if (noConnectList != null) { if (noConnectList != null) {
return noConnectList; return noConnectList;
} }

Loading…
Cancel
Save