From a07c962867a5f0d246628b18a14318154e96f1bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E7=B2=BE=E5=8D=8E?= <842761733@qq.com>
Date: Fri, 29 Nov 2019 14:40:42 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9AOffice=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=E8=BF=90=E8=A1=8C=E7=8A=B6=E6=80=81=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
jodconverter-web/pom.xml | 5 +++++
.../src/main/java/cn/keking/utils/ConverterUtils.java | 9 +++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/jodconverter-web/pom.xml b/jodconverter-web/pom.xml
index d95f6da6..ac107e2a 100644
--- a/jodconverter-web/pom.xml
+++ b/jodconverter-web/pom.xml
@@ -60,6 +60,11 @@
+
+ org.apache.commons
+ commons-lang3
+ 3.7
+
org.redisson
diff --git a/jodconverter-web/src/main/java/cn/keking/utils/ConverterUtils.java b/jodconverter-web/src/main/java/cn/keking/utils/ConverterUtils.java
index be407fdd..253088b1 100644
--- a/jodconverter-web/src/main/java/cn/keking/utils/ConverterUtils.java
+++ b/jodconverter-web/src/main/java/cn/keking/utils/ConverterUtils.java
@@ -2,6 +2,7 @@ package cn.keking.utils;
import com.sun.star.document.UpdateDocMode;
import cn.keking.extend.ControlDocumentFormatRegistry;
+import org.apache.commons.lang3.StringUtils;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeManager;
@@ -97,8 +98,8 @@ public class ConverterUtils {
} else {
flag = false;
}
- }else {
- Process p = Runtime.getRuntime().exec(new String[]{"sh","-c","ps -ef | grep "+processName});
+ } else {
+ Process p = Runtime.getRuntime().exec(new String[]{"sh","-c","ps -ef | grep " + processName});
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream os = p.getInputStream();
byte b[] = new byte[256];
@@ -106,8 +107,8 @@ public class ConverterUtils {
baos.write(b);
}
String s = baos.toString();
- if (s.indexOf(processName) >= 0) {
- String[] cmd ={"sh","-c","killall -9 "+processName};
+ if (StringUtils.ordinalIndexOf(s, processName, 3) > 0) {
+ String[] cmd ={"sh","-c","kill -15 `ps -ef|grep " + processName + "|awk 'NR==1{print $2}'`"};
Runtime.getRuntime().exec(cmd);
flag = true;
} else {