Print this page
4719 Common patchset for jdk1.7 support preparation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java
+++ new/usr/src/cmd/dtrace/test/tst/common/java_api/src/TestAbort.java
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 *
26 26 * ident "%Z%%M% %I% %E% SMI"
27 27 */
28 28
29 29 import org.opensolaris.os.dtrace.*;
30 30 import java.util.NoSuchElementException;
31 31
32 32 /**
33 33 * Regression for 6426129 abort() after close() throws
34 34 * NoSuchElementException.
35 35 */
36 36 public class TestAbort {
37 37 static boolean aborted = false;
38 38
39 39 public static void
40 40 main(String[] args)
41 41 {
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
42 42 Consumer consumer = new LocalConsumer();
43 43
44 44 // Test for deadlock (bug 6419880)
45 45 try {
46 46 consumer.open();
47 47 consumer.compile("syscall:::entry { @[execname] = count(); } " +
48 48 "tick-101ms { printa(@); }");
49 49 consumer.enable();
50 50 consumer.go();
51 51 try {
52 - Thread.currentThread().sleep(1000);
52 + Thread.sleep(1000);
53 53 } catch (InterruptedException e) {
54 54 e.printStackTrace();
55 55 System.exit(1);
56 56 }
57 57 consumer.close();
58 58 } catch (DTraceException e) {
59 59 e.printStackTrace();
60 60 System.exit(1);
61 61 }
62 62
63 63 consumer = new LocalConsumer();
64 64
65 65 // Should be able to abort an unopened consumer
66 66 try {
67 67 aborted = false;
68 68 consumer.addConsumerListener(new ConsumerAdapter() {
69 69 public void consumerStopped(ConsumerEvent e) {
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
70 70 aborted = true;
71 71 }
72 72 });
73 73 consumer.abort();
74 74 consumer.open();
75 75 consumer.compile("syscall:::entry { @[execname] = count(); } " +
76 76 "tick-101ms { printa(@); }");
77 77 consumer.enable();
78 78 consumer.go();
79 79 try {
80 - Thread.currentThread().sleep(1000);
80 + Thread.sleep(1000);
81 81 } catch (InterruptedException e) {
82 82 e.printStackTrace();
83 83 System.exit(1);
84 84 }
85 85 if (!aborted) {
86 86 throw new IllegalStateException("consumer not aborted");
87 87 }
88 88 consumer.close();
89 89 } catch (Exception e) {
90 90 e.printStackTrace();
91 91 System.exit(1);
92 92 }
93 93
94 94 consumer = new LocalConsumer();
95 95
96 96 // Should be safe to call abort() in any state
97 97 try {
98 98 consumer.abort();
99 99 consumer.open();
100 100 consumer.abort();
101 101 consumer.compile("syscall:::entry { @[execname] = count(); } " +
102 102 "tick-101ms { printa(@); }");
103 103 consumer.abort();
104 104 consumer.enable();
105 105 consumer.abort();
106 106 consumer.go();
107 107 consumer.abort();
108 108 consumer.close();
109 109 // Should be safe to call after close()
110 110 try {
111 111 consumer.abort();
112 112 } catch (NoSuchElementException e) {
113 113 e.printStackTrace();
114 114 System.exit(1);
115 115 }
116 116 } catch (Exception e) {
117 117 e.printStackTrace();
118 118 System.exit(1);
119 119 }
120 120
121 121 consumer = new LocalConsumer();
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
122 122
123 123 // Tests that close() throws expected exception when called on
124 124 // synchronized consumer.
125 125 try {
126 126 consumer.open();
127 127 consumer.compile("syscall:::entry { @[execname] = count(); } " +
128 128 "tick-101ms { printa(@); }");
129 129 consumer.enable();
130 130 consumer.go();
131 131 try {
132 - Thread.currentThread().sleep(1000);
132 + Thread.sleep(1000);
133 133 } catch (InterruptedException e) {
134 134 e.printStackTrace();
135 135 System.exit(1);
136 136 }
137 137 try {
138 138 synchronized (consumer) {
139 139 consumer.close();
140 140 }
141 141 } catch (IllegalThreadStateException e) {
142 142 try {
143 143 consumer.close();
144 144 System.out.println("Successful");
145 145 System.exit(0);
146 146 } catch (NoSuchElementException x) {
147 147 x.printStackTrace();
148 148 System.exit(1);
149 149 }
150 150 }
151 151 } catch (DTraceException e) {
152 152 e.printStackTrace();
153 153 System.exit(1);
154 154 }
155 155 System.err.println("Failed");
156 156 System.exit(1);
157 157 }
158 158 }
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX