112 ProcessBuilder pb = new ProcessBuilder(); 113 pb.command(launcher.getCommand()); 114 System.out.println(pb.command().stream().collect(Collectors.joining(" "))); 115 116 try { 117 p = pb.start(); 118 } catch (Exception attachE) { 119 throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE); 120 } 121 122 // Issue the 'jstack' input at the clhsdb prompt. 123 OutputStream input = p.getOutputStream(); 124 String str = "jstack > " + JSTACK_OUT_FILE + "\nquit\n"; 125 try { 126 input.write(str.getBytes()); 127 input.flush(); 128 } catch (IOException ioe) { 129 throw new Error("Problem issuing the jstack command: " + str, ioe); 130 } 131 132 try { 133 p.waitFor(); 134 } catch (InterruptedException ie) { 135 throw new Error("Problem awaiting the child process: " + ie, ie); 136 } 137 138 int exitValue = p.exitValue(); 139 if (exitValue != 0) { 140 String output; 141 try { 142 output = new OutputAnalyzer(p).getOutput(); 143 } catch (IOException ioe) { 144 throw new Error("Can't get failed clhsdb process output: " + ioe, ioe); 145 } 146 throw new AssertionError("clhsdb wasn't run successfully: " + output); 147 } 148 } 149 150 public static void main (String... args) throws Exception { 151 152 LingeredApp app = null; 153 154 if (!Platform.shouldSAAttach()) { 155 System.out.println("SA attach not expected to work - test skipped."); 156 return; 157 } 158 159 try { 160 List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions()); 161 162 app = new LingeredAppWithLock(); 163 LingeredApp.startApp(vmArgs, app); 164 System.out.println ("Started LingeredApp with pid " + app.getPid()); 165 startClhsdbForLock(app.getPid()); 166 verifyJStackOutput(); 167 } finally { | 112 ProcessBuilder pb = new ProcessBuilder(); 113 pb.command(launcher.getCommand()); 114 System.out.println(pb.command().stream().collect(Collectors.joining(" "))); 115 116 try { 117 p = pb.start(); 118 } catch (Exception attachE) { 119 throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE); 120 } 121 122 // Issue the 'jstack' input at the clhsdb prompt. 123 OutputStream input = p.getOutputStream(); 124 String str = "jstack > " + JSTACK_OUT_FILE + "\nquit\n"; 125 try { 126 input.write(str.getBytes()); 127 input.flush(); 128 } catch (IOException ioe) { 129 throw new Error("Problem issuing the jstack command: " + str, ioe); 130 } 131 132 OutputAnalyzer output = new OutputAnalyzer(p); 133 134 try { 135 p.waitFor(); 136 } catch (InterruptedException ie) { 137 p.destroyForcibly(); 138 throw new Error("Problem awaiting the child process: " + ie, ie); 139 } 140 141 output.shouldHaveExitValue(0); 142 } 143 144 public static void main (String... args) throws Exception { 145 146 LingeredApp app = null; 147 148 if (!Platform.shouldSAAttach()) { 149 System.out.println("SA attach not expected to work - test skipped."); 150 return; 151 } 152 153 try { 154 List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions()); 155 156 app = new LingeredAppWithLock(); 157 LingeredApp.startApp(vmArgs, app); 158 System.out.println ("Started LingeredApp with pid " + app.getPid()); 159 startClhsdbForLock(app.getPid()); 160 verifyJStackOutput(); 161 } finally { |