diff options
| author | tanghao <admin@LAPTOP-QCSKVLI9> | 2021-03-25 09:26:56 +0800 |
|---|---|---|
| committer | tanghao <admin@LAPTOP-QCSKVLI9> | 2021-03-25 09:26:56 +0800 |
| commit | 2cd2e65b1bf6cce2d9a40ba1fffb55dee84638a5 (patch) | |
| tree | e9a5f0e726f5a29745e88550b96544b7043052e8 | |
| parent | 6626ec94766b7230e60a46b948d84050a0017ba7 (diff) | |
fix: 修复eal4 Locale dependent result 部分bug Explicit thread handling bug
5 files changed, 58 insertions, 34 deletions
diff --git a/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoIconServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoIconServiceImpl.java index 8da02450..1585cfb9 100644 --- a/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoIconServiceImpl.java +++ b/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoIconServiceImpl.java @@ -1,5 +1,6 @@ package com.nis.modules.project.service.impl; +import cn.hutool.core.util.StrUtil; import cn.hutool.log.Log; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -69,7 +70,8 @@ public class TopoIconServiceImpl extends ServiceImpl<TopoIconDao, TopoIcon> impl byte[] bytes = Base64.getDecoder().decode(icon.getBytes()); try (OutputStream os = new BufferedOutputStream(response.getOutputStream());) { - String contentType = "jpg".equals(icon.getType().toLowerCase()) ? "jpeg" : icon.getType().toLowerCase(); +// String contentType = "jpg".equals(icon.getType().toLowerCase()) ? "jpeg" : icon.getType().toLowerCase(); + String contentType = StrUtil.equals("jpg", icon.getType()) ? "jpeg" : icon.getType().toLowerCase(); response.setContentType("image/" + contentType); response.setHeader("Content-Disposition", "inline"); os.write(bytes); @@ -86,16 +88,22 @@ public class TopoIconServiceImpl extends ServiceImpl<TopoIconDao, TopoIcon> impl throw new NZException(RCode.PROJECT_TOPOICON_FILETYPE_ERROR); } - String fileType = filename.substring(filename.lastIndexOf(".") + 1); - fileType = fileType.toLowerCase(); - switch (fileType){ - case "jpg":break; - case "jpeg":break; - case "png":break; - case "gif":break; - default: - throw new NZException(RCode.PROJECT_TOPOICON_FILETYPE_ERROR); +// String fileType = filename.substring(filename.lastIndexOf(".") + 1); +// fileType = fileType.toLowerCase(); + String fileType = StrUtil.sub(filename, StrUtil.lastIndexOf(filename, ".", filename.length(), false)+1,filename.length()); + if(!StrUtil.equals(fileType, "jpg",true) || !StrUtil.equals(fileType, "jpeg",true) || + !StrUtil.equals(fileType, "png",true) || + !StrUtil.equals(fileType, "gif",true)) { + throw new NZException(RCode.PROJECT_TOPOICON_FILETYPE_ERROR); } + /*switch (fileType){ + case "jpg":break; + case "jpeg":break; + case "png":break; + case "gif":break; + default: + throw new NZException(RCode.PROJECT_TOPOICON_FILETYPE_ERROR); + }*/ } @Override diff --git a/nz-admin/src/main/java/com/nis/modules/promserver/service/impl/PromserverProxyServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/promserver/service/impl/PromserverProxyServiceImpl.java index 8423c174..14869109 100644 --- a/nz-admin/src/main/java/com/nis/modules/promserver/service/impl/PromserverProxyServiceImpl.java +++ b/nz-admin/src/main/java/com/nis/modules/promserver/service/impl/PromserverProxyServiceImpl.java @@ -1,5 +1,6 @@ package com.nis.modules.promserver.service.impl; +import cn.hutool.core.util.StrUtil; import cn.hutool.log.Log; import com.alibaba.fastjson.JSONObject; import com.nis.common.exception.NZException; @@ -49,20 +50,29 @@ public class PromserverProxyServiceImpl implements PromserverProxyService { try { client = HttpClientBuilder.create().build(); HttpRequestBase request = null; - switch (method.toUpperCase()) { - case "GET": - request = new HttpGet(promUrl); - break; - case "POST": - request = new HttpPost(promUrl); - case "PUT": - request = new HttpPut(promUrl); - case "DELETE": - request = new HttpDelete(promUrl); - default: - request = new HttpPost(promUrl); - break; - } + if(StrUtil.equals(method, "GET",true)) { + request = new HttpGet(promUrl); + }else if(StrUtil.equals(method, "PUT",true)) { + request = new HttpPut(promUrl); + }else if(StrUtil.equals(method, "DELETE",true)) { + request = new HttpDelete(promUrl); + }else { + request = new HttpPost(promUrl); + } + /*switch (method) { + case "GET": + request = new HttpGet(promUrl); + break; + case "POST": + request = new HttpPost(promUrl); + case "PUT": + request = new HttpPut(promUrl); + case "DELETE": + request = new HttpDelete(promUrl); + default: + request = new HttpPost(promUrl); + break; + }*/ if(!"GET".equalsIgnoreCase(method)&& !"DELETE".equalsIgnoreCase(method)) { String queryString = genQueryString(params); StringEntity entity = new StringEntity(queryString,"utf-8"); diff --git a/nz-admin/src/main/java/com/nis/modules/sys/service/impl/SnmpMibServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/sys/service/impl/SnmpMibServiceImpl.java index fffa71a0..e7da3381 100644 --- a/nz-admin/src/main/java/com/nis/modules/sys/service/impl/SnmpMibServiceImpl.java +++ b/nz-admin/src/main/java/com/nis/modules/sys/service/impl/SnmpMibServiceImpl.java @@ -267,7 +267,8 @@ public class SnmpMibServiceImpl extends ServiceImpl<SnmpMibDao, SnmpMib> impleme type = mvs.getType().getName(); if (StringUtils.isNotEmpty(type) && StringUtils.isEmpty(mo.getType())) { - if (type.toUpperCase().contains(Constant.MIB_IDENTIFIER_TYPE)) { + String upperCase = type.toUpperCase(); + if (StrUtil.contains(upperCase, Constant.MIB_IDENTIFIER_TYPE)) { mo.setType(Constant.MIB_IDENTIFIER_TYPE); } else { mo.setType(Constant.MIB_OBJECT_TYPE); diff --git a/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalClient.java b/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalClient.java index 8c50badf..a15353e1 100644 --- a/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalClient.java +++ b/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalClient.java @@ -51,11 +51,14 @@ import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import static com.nis.common.utils.CommonUtils.notEmpty; public class TerminalClient { private static final Log logger = Log.get(); + private static final ExecutorService executorService = Executors.newCachedThreadPool(); private String clientId;//每次生成的唯一值token private String httpSessionId;//打开该终端的SessionId private WebSocketSession webSocketSession; @@ -164,7 +167,8 @@ public class TerminalClient { sb.append("Login success,use user " + params.get("username") + " \r\n"); webSocketSession.sendMessage(new TextMessage(sb.toString())); - new Thread(new Runnable() { + + executorService.execute((new Runnable() { @Override public void run() { TerminalCmdService terminalCmdService = (TerminalCmdService) TerminalSession.clientAttributeInfo.get("terminalCmdService"); @@ -269,7 +273,7 @@ public class TerminalClient { } } - }).start(); + })); } @@ -338,7 +342,7 @@ public class TerminalClient { params = new HashMap<>(); } String pin = params.get(Constant.PIN); - new Thread(new Runnable() { + executorService.execute(new Runnable() { @Override public void run() { TerminalLogService terminalLogService = (TerminalLogService) TerminalSession.clientAttributeInfo.get("terminalLogService"); @@ -540,7 +544,7 @@ public class TerminalClient { } } - }).start(); + }); } /** @@ -842,7 +846,7 @@ public class TerminalClient { sendTempCmd = true; write(String.format("echo %s$(pwd)\r", this.sendTempCmdId)); //等待获取返回的路径... - Thread.sleep(100); +// Thread.sleep(100); sendTempCmd = false; if (pwd == null) { throw new RuntimeException("Sftp upload file target path error!"); @@ -854,7 +858,7 @@ public class TerminalClient { } channelSftp.put(file, dst, new SftpMonitor(fileSize)); - } catch (InterruptedException | JSchException | SftpException | IOException e) { + } catch (JSchException | SftpException | IOException e) { throw e; } finally { //exit @@ -885,7 +889,7 @@ public class TerminalClient { sendTempCmd = true; write(String.format("echo %s$(pwd)\r", this.sendTempCmdId)); //等待获取返回的路径... - Thread.sleep(100); +// Thread.sleep(100); sendTempCmd = false; if (pwd == null) { throw new RuntimeException("Sftp upload file target path error!"); @@ -915,7 +919,7 @@ public class TerminalClient { outputStream.flush(); i = is.read(buff); } - } catch (InterruptedException | JSchException | SftpException | IOException e) { + } catch (JSchException | SftpException | IOException e) { throw e; } finally { if(outputStream!=null) { diff --git a/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalHandler.java b/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalHandler.java index 4c163d73..40d3ac7f 100644 --- a/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalHandler.java +++ b/nz-admin/src/main/java/com/nis/modules/terminal/config/TerminalHandler.java @@ -250,7 +250,8 @@ public class TerminalHandler extends TextWebSocketHandler { } catch (Exception e) { logger.error("error info :",e); logger.error(e); - if (e.getMessage().toLowerCase().contains("auth fail")) { + String lowerCase = e.getMessage().toLowerCase(); + if (StrUtil.contains(lowerCase, "auth fail")) { session.sendMessage(new TextMessage("Login fail, Please check account info is accurate. \r\n")); } else if (e.getLocalizedMessage().replaceAll("\\s+", "").contentEquals("Operationtimedout")) { session.sendMessage(new TextMessage("Sorry! Connect timed out, please try again. \r\n")); |
