Commit c5e0e901 authored by zhangsen's avatar zhangsen

根据代码检查工具处理阻断漏洞 0223

parent 01459f5a
......@@ -883,7 +883,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public void run() {
boolean isRunning = true;
int k = 0;
while (isRunning) {
k++;
isRunning = k < Integer.MAX_VALUE;
AlarmParam deviceData = null;
try {
deviceData = blockingQueue.take();
......
......@@ -98,7 +98,11 @@ public class RsDataQueue {
private Runnable task_runnable = new Runnable() {
@Override
public void run() {
while (true) {
int k = 0;
boolean b = true;
while (b) {
k++;
b = k < Integer.MAX_VALUE;
try {
FmeaMessage fmeaMessage = blockingQueue.take();
if (riskSourceService != null) {
......
......@@ -34,12 +34,14 @@ public class AmosThreadPool {
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
if (null != instance) {
return instance;
}
synchronized (AmosThreadPool.class) {
if (instance != null) {
return instance;
}
instance = new AmosThreadPool();
}
return instance;
}
......
......@@ -42,12 +42,14 @@ public class TriggerKeyQueue {
* @return
*/
public static TriggerKeyQueue getInstance() {
if (instance == null) {
synchronized (TriggerKeyQueue.class) {
if (instance == null) {
instance = new TriggerKeyQueue();
if (null != instance) {
return instance;
}
synchronized (TriggerKeyQueue.class) {
if (instance != null) {
return instance;
}
instance = new TriggerKeyQueue();
}
return instance;
}
......
......@@ -34,18 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
e.printStackTrace();
......@@ -58,21 +52,14 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try (InputStream stream = new FileInputStream(new File(fileName));) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
}
......
package com.yeejoin.amos.latentdanger.core.threadpool;
import com.yeejoin.amos.latentdanger.business.constants.Constants;
import com.yeejoin.amos.latentdanger.business.trigger.TriggerKeyQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -33,12 +34,14 @@ public class AmosThreadPool {
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
if (null != instance) {
return instance;
}
synchronized (AmosThreadPool.class) {
if (instance != null) {
return instance;
}
instance = new AmosThreadPool();
}
return instance;
}
......
......@@ -42,12 +42,14 @@ public class TriggerKeyQueue {
* @return
*/
public static TriggerKeyQueue getInstance() {
if (instance == null) {
synchronized (TriggerKeyQueue.class) {
if (instance == null) {
instance = new TriggerKeyQueue();
if (null != instance) {
return instance;
}
synchronized (TriggerKeyQueue.class) {
if (instance != null) {
return instance;
}
instance = new TriggerKeyQueue();
}
return instance;
}
......
......@@ -40,6 +40,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -64,11 +65,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -76,17 +74,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -97,20 +84,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -169,34 +146,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content);
content = br.readLine();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -208,34 +170,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
content = br.readLine();
}
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
}
return buffer;
}
......@@ -245,28 +192,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -355,11 +289,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -368,20 +299,7 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
......@@ -1254,35 +1172,28 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws
*/
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
try {
//通过文件路径获得File对象
File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try ( FileInputStream in = new FileInputStream(file);
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
......
......@@ -34,17 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try (InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
......
......@@ -33,12 +33,14 @@ public class AmosThreadPool {
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
if (null != instance) {
return instance;
}
synchronized (AmosThreadPool.class) {
if (instance != null) {
return instance;
}
instance = new AmosThreadPool();
}
return instance;
}
......
......@@ -42,12 +42,14 @@ public class TriggerKeyQueue {
* @return
*/
public static TriggerKeyQueue getInstance() {
if (instance == null) {
synchronized (TriggerKeyQueue.class) {
if (instance == null) {
instance = new TriggerKeyQueue();
if (null != instance) {
return instance;
}
synchronized (TriggerKeyQueue.class) {
if (instance != null) {
return instance;
}
instance = new TriggerKeyQueue();
}
return instance;
}
......
package com.yeejoin.amos.patrol.core.threadpool;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.trigger.TriggerKeyQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -33,12 +34,14 @@ public class AmosThreadPool {
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
if (null != instance) {
return instance;
}
synchronized (AmosThreadPool.class) {
if (instance != null) {
return instance;
}
instance = new AmosThreadPool();
}
return instance;
}
......
......@@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -209,14 +210,10 @@ public class FileController {
} else {
processData = DocUtil.processDocx(data);
}
String htmlContent = (String) processData.get("html");
try {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), "UTF-8"));
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFileName), StandardCharsets.UTF_8));) {
writer.write(htmlContent);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -42,12 +42,14 @@ public class TriggerKeyQueue {
* @return
*/
public static TriggerKeyQueue getInstance() {
if (instance == null) {
synchronized (TriggerKeyQueue.class) {
if (instance == null) {
instance = new TriggerKeyQueue();
if (null != instance) {
return instance;
}
synchronized (TriggerKeyQueue.class) {
if (instance != null) {
return instance;
}
instance = new TriggerKeyQueue();
}
return instance;
}
......
......@@ -39,6 +39,7 @@ import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -63,11 +64,8 @@ public class FileHelper {
* @return
*/
public static boolean isExcel2003(File file) {
InputStream is = null;
Workbook wb = null;
try {
is = new FileInputStream(file);
wb = WorkbookFactory.create(is);
try (InputStream is = new FileInputStream(file);
Workbook wb = WorkbookFactory.create(is);) {
if (wb instanceof XSSFWorkbook) {
return false;
} else if (wb instanceof HSSFWorkbook) {
......@@ -75,17 +73,6 @@ public class FileHelper {
}
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
if (null != wb) {
wb.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -96,20 +83,10 @@ public class FileHelper {
* @return
*/
public static boolean isWord2003(File file) {
InputStream is = null;
try {
is = new FileInputStream(file);
new HWPFDocument(is);
try (InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is);) {
} catch (Exception e) {
return false;
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
......@@ -168,34 +145,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content);
content = br.readLine();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return buffer;
}
......@@ -207,34 +169,19 @@ public class FileHelper {
*/
public static StringBuffer readFile(String path, String split) {
StringBuffer buffer = new StringBuffer();
InputStream is = null;
BufferedReader br = null;
try {
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(is));
try (InputStream is = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String content = br.readLine();
while (null != content) {
buffer.append(content).append(split);
content = br.readLine();
}
}
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
if (null != br) {
br.close();
}
} catch (Exception exception2) {
exception2.printStackTrace();
}
}
return buffer;
}
......@@ -244,28 +191,15 @@ public class FileHelper {
* @param path 写入内容的文件路径
*/
public static void writeFile(String content, String path) {
OutputStream fos = null;
BufferedWriter bw = null;
try {
File file = new File(path);
try (OutputStream fos = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8))) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
} catch (FileNotFoundException fnfe) {
} catch (IOException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioException) {
System.err.println(ioException.getMessage());
}
}
}
......@@ -354,11 +288,8 @@ public class FileHelper {
public static void rmrBlankLines(String inputFile, String outPutFile) throws IOException {
File htmFile = new File(inputFile);
// 以GB2312读取文件
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new FileReader(htmFile));
bw = new BufferedWriter(new FileWriter(new File(outPutFile)));
try (BufferedReader br = new BufferedReader(new FileReader(htmFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outPutFile)));) {
String result = null;
while (null != (result = br.readLine())) {
if (!"".equals(result.trim())) {
......@@ -367,22 +298,9 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != br) {
br.close();
}
if (null != bw) {
bw.close();
}
} catch (Exception e) {
}
}
}
/**
* @param htmFilePath
* @throws IOException
......@@ -1253,35 +1171,28 @@ private static void defaultExport(List<Map<String, Object>> list, String fileNam
* @throws
*/
public static void getExcel(String url, String fileName, HttpServletResponse response,HttpServletRequest request){
try {
//通过文件路径获得File对象
File file = new File(url);
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名
try {
response.setHeader("Content-disposition", "attachment; filename=\""
+ encodeChineseDownloadFileName(request, fileName+".xls") +"\"");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try ( FileInputStream in = new FileInputStream(file);
OutputStream out = new BufferedOutputStream(response.getOutputStream());) {
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"); //中文文件名
//通过文件路径获得File对象
File file = new File(url);
FileInputStream in = new FileInputStream(file);
//3.通过response获取OutputStream对象(out)
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b=in.read(buffer)) != -1){
out.write(buffer,0,b); //4.写到输出流(out)中
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
log.error("下载Excel模板异常", e);
}
......
......@@ -34,17 +34,12 @@ public class TikaUtils {
public static String fileToTxt(File file) {
org.apache.tika.parser.Parser parser = new AutoDetectParser();
try {
InputStream inputStream = new FileInputStream(file);
try(InputStream inputStream = new FileInputStream(file);) {
DefaultHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext parseContext = new ParseContext();
parseContext.set(Parser.class, parser);
parser.parse(inputStream, handler, metadata, parseContext);
/*
* for (String string : metadata.names()) {
* System.out.println(string+":"+metadata.get(string)); }
*/
inputStream.close();
return handler.toString();
} catch (Exception e) {
......@@ -58,21 +53,14 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try ( InputStream stream = new FileInputStream(new File(fileName));) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
FileHelper.parse(outPutFile + ".html");
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return null;
}
......
......@@ -33,12 +33,14 @@ public class AmosThreadPool {
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
if (null != instance) {
return instance;
}
synchronized (AmosThreadPool.class) {
if (instance != null) {
return instance;
}
instance = new AmosThreadPool();
}
return instance;
}
......
......@@ -193,19 +193,12 @@ public class WordPowerUtils {
if (!file.exists()) {
return "";
}
InputStream in = null;
byte[] data = null;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
try (InputStream in = new FileInputStream(file)) {
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
......
......@@ -334,15 +334,13 @@ public class CheckResultImpl extends ServiceImpl<CheckResultMapper, CheckResult>
* @return
*/
private static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
try (FileInputStream in = new FileInputStream(file);) {
byte[] data = new byte[in.available()];
in.read(data);
in.close();
return data;
} catch (Exception e) {
e.printStackTrace();
return null;
return new byte[0];
}
}
......
......@@ -32,12 +32,14 @@ public class AmosThreadPool {
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
if (null != instance) {
return instance;
}
synchronized (AmosThreadPool.class) {
if (instance != null) {
return instance;
}
instance = new AmosThreadPool();
}
return instance;
}
......
......@@ -22,6 +22,8 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import net.sf.json.JSONObject;
import static com.alibaba.fastjson.JSON.parseArray;
@Slf4j
@Component
public class EmqMessageService extends EmqxListener {
......@@ -55,7 +57,7 @@ public class EmqMessageService extends EmqxListener {
e.printStackTrace();
}
list = com.alibaba.fastjson.JSONObject.parseArray(json, Map.class);
list = parseArray(json, Map.class);
String[] split = topics.split(",");
Arrays.stream(split).forEach(e-> {
......@@ -78,7 +80,11 @@ public class EmqMessageService extends EmqxListener {
Runnable task_runnable = new Runnable() {
public void run() {
while (true) {
int k = 0;
boolean b = true;
while (b) {
k++;
b = k < Integer.MAX_VALUE;
try {
JSONObject messageResult = blockingQueue.take();
JSONObject result = messageResult.getJSONObject("result");
......@@ -89,6 +95,7 @@ public class EmqMessageService extends EmqxListener {
}
});
} catch (Exception e) {
Thread.currentThread().interrupt();
log.info("发送kafka消息失败 ====> message: {}", e.getMessage());
}
}
......
......@@ -66,7 +66,11 @@ public class AppSpeechTranscriber {
DatagramPacket datagramPacket = new DatagramPacket(b, b.length);
logger.warn("serverSocket已启动,地址:" + localIpAddress
+ "监听端口:" + serverSocket.getLocalPort() + " 等待语音融合系统推送数据...");
while (true) {
int k = 0;
boolean b1 = true;
while (b1) {
k++;
b1 = k < Integer.MAX_VALUE;
serverSocket.receive(datagramPacket);
if (transcriber == null) {
logger.warn("收到第一个数据包:" + b.length + " 开始进行语音翻译");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment