首先该服务是使用java 调用控制台脚本启动的jar包
同时java调用 服务的控制部分也理所应当的
Process process = null; try { process = Runtime.getRuntime().exec(cmd, null, null); process.getOutputStream().close(); BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream(), System.getProperty("sun.jnu.encoding"))); BufferedReader outputErr = new BufferedReader(new InputStreamReader(process.getErrorStream(), System.getProperty("sun.jnu.encoding"))); String line = ""; Long l1 = 0L; Long l2 = 0L; while ((line = output.readLine()) != null) { l1++; log.debug(line); System.out.println(line); } while ((line = outputErr.readLine()) != null) { l2++; log.debug(line); System.out.println(line); } process.waitFor(); outputErr.close(); output.close(); } catch (Exception e) { log.error(entity.getServiceName() + errMsg, e); } finally { if (process != null) { process.destroy(); } }
OutputStream、InputStream,ErrorStream 都处理过了
但是还是在 e.printStackTrace 导致了服务请求pending,而且不是高压测试,只是一个请求马上就无返回了。
标签:process,System,printStackTrace,BufferedReader,new,控制台,null,line,pending From: https://www.cnblogs.com/prprprcom/p/17616519.html