302 }
303 return value;
304 }
305
306 /*
307 * Utility method to read data into a String.
308 */
309 String readErrorMessage(InputStream sis) throws IOException {
310 String s;
311 StringBuilder message = new StringBuilder();
312 BufferedReader br = new BufferedReader(new InputStreamReader(sis));
313 while ((s = br.readLine()) != null) {
314 message.append(s);
315 }
316 return message.toString();
317 }
318
319
320 // -- attach timeout support
321
322 private static long defaultAttachTimeout = 5000;
323 private volatile long attachTimeout;
324
325 /*
326 * Return attach timeout based on the value of the sun.tools.attach.attachTimeout
327 * property, or the default timeout if the property is not set to a positive
328 * value.
329 */
330 long attachTimeout() {
331 if (attachTimeout == 0) {
332 synchronized(this) {
333 if (attachTimeout == 0) {
334 try {
335 String s =
336 System.getProperty("sun.tools.attach.attachTimeout");
337 attachTimeout = Long.parseLong(s);
338 } catch (SecurityException se) {
339 } catch (NumberFormatException ne) {
340 }
341 if (attachTimeout <= 0) {
342 attachTimeout = defaultAttachTimeout;
|
302 }
303 return value;
304 }
305
306 /*
307 * Utility method to read data into a String.
308 */
309 String readErrorMessage(InputStream sis) throws IOException {
310 String s;
311 StringBuilder message = new StringBuilder();
312 BufferedReader br = new BufferedReader(new InputStreamReader(sis));
313 while ((s = br.readLine()) != null) {
314 message.append(s);
315 }
316 return message.toString();
317 }
318
319
320 // -- attach timeout support
321
322 private static long defaultAttachTimeout = 10000;
323 private volatile long attachTimeout;
324
325 /*
326 * Return attach timeout based on the value of the sun.tools.attach.attachTimeout
327 * property, or the default timeout if the property is not set to a positive
328 * value.
329 */
330 long attachTimeout() {
331 if (attachTimeout == 0) {
332 synchronized(this) {
333 if (attachTimeout == 0) {
334 try {
335 String s =
336 System.getProperty("sun.tools.attach.attachTimeout");
337 attachTimeout = Long.parseLong(s);
338 } catch (SecurityException se) {
339 } catch (NumberFormatException ne) {
340 }
341 if (attachTimeout <= 0) {
342 attachTimeout = defaultAttachTimeout;
|