author | martin |
Tue, 15 Sep 2015 21:56:04 -0700 | |
changeset 32649 | 2ee9017c7597 |
parent 19395 | e31689b0bb67 |
permissions | -rw-r--r-- |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
1 |
/* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
4 |
* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
8 |
* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
13 |
* accompanied this code). |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
14 |
* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
18 |
* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
21 |
* questions. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
22 |
*/ |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
23 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
24 |
/* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
25 |
* @test |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
26 |
* @bug 8002070 8013382 |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
27 |
* @summary Remove the stack search for a resource bundle Logger to use |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
28 |
* @author Jim Gish |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
29 |
* @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
30 |
* @run main/othervm ResourceBundleSearchTest |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
31 |
*/ |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
32 |
import java.net.URL; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
33 |
import java.net.URLClassLoader; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
34 |
import java.nio.file.Paths; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
35 |
import java.util.ArrayList; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
36 |
import java.util.List; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
37 |
import java.util.Locale; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
38 |
import java.util.MissingResourceException; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
39 |
import java.util.ResourceBundle; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
40 |
import java.util.logging.Logger; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
41 |
|
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
42 |
/** |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
43 |
* This class tests various scenarios of loading resource bundles from |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
44 |
* java.util.logging. Since jtreg uses the logging system, it is necessary to |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
45 |
* run these tests using othervm mode to ensure no interference from logging |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
46 |
* initialization by jtreg |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
47 |
*/ |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
48 |
public class ResourceBundleSearchTest { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
49 |
|
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
19395
diff
changeset
|
50 |
private static final boolean DEBUG = false; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
19395
diff
changeset
|
51 |
private static final String LOGGER_PREFIX = "myLogger."; |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
52 |
private static int loggerNum = 0; |
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
19395
diff
changeset
|
53 |
private static final String PROP_RB_NAME = "ClassPathTestBundle"; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
19395
diff
changeset
|
54 |
private static final String TCCL_TEST_BUNDLE = "ContextClassLoaderTestBundle"; |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
55 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
56 |
private static int numPass = 0; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
57 |
private static int numFail = 0; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
58 |
private static List<String> msgs = new ArrayList<>(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
59 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
60 |
// This test has been falling in timeout - so we're adding some |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
61 |
// time stamp here and there to help diagnose whether it's a |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
62 |
// simple system slowness or whether there's a deeper issue, |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
63 |
// like a deadlock. The timeout issue should be fixed now, |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
64 |
// but we leave the time stamps in case it reappears. |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
65 |
// |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
66 |
static final long stamp = System.currentTimeMillis(); |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
67 |
private static String getTimeStamp() { |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
68 |
long time = System.currentTimeMillis(); |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
69 |
long delta = time - stamp; |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
70 |
long min = delta/60000; |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
71 |
long sec = (delta - min * 60000) / 10000; |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
72 |
long msec = delta - min * 60000 - sec * 1000; |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
73 |
return (min == 0 ? "" : (min + " min. ")) + |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
74 |
(sec == 0 ? "" : (sec + " sec. ")) + |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
75 |
(msec == 0 ? "" : (msec + "ms.")); |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
76 |
} |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
77 |
|
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
78 |
public static void main(String[] args) throws Throwable { |
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
79 |
System.out.println("ResourceBundleSearchTest starting: "+getTimeStamp()); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
80 |
ResourceBundleSearchTest test = new ResourceBundleSearchTest(); |
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
81 |
try { |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
82 |
test.runTests(); |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
83 |
} finally { |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
84 |
System.out.println("ResourceBundleSearchTest terminated: "+getTimeStamp()); |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
85 |
} |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
86 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
87 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
88 |
private void runTests() throws Throwable { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
89 |
// ensure we are using en as the default Locale so we can find the resource |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
90 |
Locale.setDefault(Locale.ENGLISH); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
91 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
92 |
ClassLoader myClassLoader = ClassLoader.getSystemClassLoader(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
93 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
94 |
// Find out where we are running from so we can setup the URLClassLoader URL |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
95 |
String userDir = System.getProperty("user.dir"); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
96 |
String testDir = System.getProperty("test.src", userDir); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
97 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
98 |
URL[] urls = new URL[1]; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
99 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
100 |
urls[0] = Paths.get(testDir, "resources").toUri().toURL(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
101 |
URLClassLoader rbClassLoader = new URLClassLoader(urls); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
102 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
103 |
int testnb = 1; |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
104 |
System.out.println("ResourceBundleSearchTest starting test #"+(testnb++)+": "+getTimeStamp()); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
105 |
// Test 1 - can we find a Logger bundle from doing a stack search? |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
106 |
// We shouldn't be able to |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
107 |
assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch"); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
108 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
109 |
System.out.println("ResourceBundleSearchTest starting test #"+(testnb++)+": "+getTimeStamp()); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
110 |
// Test 2 - can we find a Logger bundle off of the Thread context class |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
111 |
// loader? We should be able to. |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
112 |
assertTrue(testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader), |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
113 |
"2-testGetBundleFromTCCL"); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
114 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
115 |
System.out.println("ResourceBundleSearchTest starting test #"+(testnb++)+": "+getTimeStamp()); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
116 |
// Test 3 - Can we find a Logger bundle from the classpath? We should be |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
117 |
// able to. We'll first check to make sure the setup is correct and |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
118 |
// it actually is on the classpath before checking whether logging |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
119 |
// can see it there. |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
120 |
if (isOnClassPath(PROP_RB_NAME, myClassLoader)) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
121 |
debug("We should be able to see " + PROP_RB_NAME + " on the classpath"); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
122 |
assertTrue(testGetBundleFromSystemClassLoader(PROP_RB_NAME), |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
123 |
"3-testGetBundleFromSystemClassLoader"); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
124 |
} else { |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
125 |
throw new Exception("TEST SETUP FAILURE: Cannot see " + PROP_RB_NAME |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
126 |
+ " on the classpath"); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
127 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
128 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
129 |
System.out.println("ResourceBundleSearchTest starting test #"+(testnb++)+": "+getTimeStamp()); |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
130 |
// Test 4 - we should be able to find a bundle from the caller's |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
131 |
// classloader, but only one level up. |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
132 |
assertTrue(testGetBundleFromCallersClassLoader(), |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
133 |
"4-testGetBundleFromCallersClassLoader"); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
134 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
135 |
System.out.println("ResourceBundleSearchTest starting test #"+(testnb++)+": "+getTimeStamp()); |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
136 |
// Test 5 - this ensures that getAnonymousLogger(String rbName) |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
137 |
// can find the bundle from the caller's classloader |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
138 |
assertTrue(testGetAnonymousLogger(), "5-testGetAnonymousLogger"); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
139 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
140 |
System.out.println("ResourceBundleSearchTest starting test #"+(testnb++)+": "+getTimeStamp()); |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
141 |
// Test 6 - first call getLogger("myLogger"). |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
142 |
// Then call getLogger("myLogger","bundleName") from a different ClassLoader |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
143 |
// Make sure we find the bundle |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
144 |
assertTrue(testGetBundleFromSecondCallersClassLoader(), |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
145 |
"6-testGetBundleFromSecondCallersClassLoader"); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
146 |
|
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
147 |
System.out.println("ResourceBundleSearchTest generating report: "+getTimeStamp()); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
148 |
report(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
149 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
150 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
151 |
private void report() throws Exception { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
152 |
System.out.println("Num passed = " + numPass + " Num failed = " + numFail); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
153 |
if (numFail > 0) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
154 |
// We only care about the messages if they were errors |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
155 |
for (String msg : msgs) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
156 |
System.out.println(msg); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
157 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
158 |
throw new Exception(numFail + " out of " + (numPass + numFail) |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
159 |
+ " tests failed."); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
160 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
161 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
162 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
163 |
public void assertTrue(boolean testResult, String testName) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
164 |
if (testResult) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
165 |
numPass++; |
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
166 |
System.out.println("PASSED: " + testName); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
167 |
} else { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
168 |
numFail++; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
169 |
System.out.println("FAILED: " + testName |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
170 |
+ " was supposed to return true but did NOT!"); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
171 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
172 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
173 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
174 |
public void assertFalse(boolean testResult, String testName) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
175 |
if (!testResult) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
176 |
numPass++; |
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
177 |
System.out.println("PASSED: " + testName); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
178 |
} else { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
179 |
numFail++; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
180 |
System.out.println("FAILED: " + testName |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
181 |
+ " was supposed to return false but did NOT!"); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
182 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
183 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
184 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
185 |
public boolean testGetBundleFromStackSearch() throws Throwable { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
186 |
// This should fail. This was the old functionality to search up the |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
187 |
// caller's call stack |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
188 |
TwiceIndirectlyLoadABundle indirectLoader = new TwiceIndirectlyLoadABundle(); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
189 |
return indirectLoader.loadAndTest(); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
190 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
191 |
|
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
192 |
public boolean testGetBundleFromCallersClassLoader() throws Throwable { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
193 |
// This should pass. This exercises getting the bundle using the |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
194 |
// class loader of the caller (one level up) |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
195 |
IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
196 |
return indirectLoader.loadAndTest(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
197 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
198 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
199 |
public boolean testGetBundleFromTCCL(String bundleName, |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
200 |
ClassLoader setOnTCCL) throws InterruptedException { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
201 |
// This should succeed. We should be able to get the bundle from the |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
202 |
// thread context class loader |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
203 |
debug("Looking for " + bundleName + " using TCCL"); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
204 |
LoggingThread lr = new LoggingThread(bundleName, setOnTCCL); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
205 |
lr.start(); |
19395
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
206 |
try { |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
207 |
lr.join(); |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
208 |
} catch (InterruptedException ex) { |
e31689b0bb67
8019948: java/util/logging/bundlesearch/ResourceBundleSearchTest.java is failing intermittently
dfuchs
parents:
17487
diff
changeset
|
209 |
throw ex; |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
210 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
211 |
msgs.add(lr.msg); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
212 |
return lr.foundBundle; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
213 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
214 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
215 |
/* |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
216 |
* @param String bundleClass |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
217 |
* @param ClassLoader to use for search |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
218 |
* @return true iff bundleClass is on system classpath |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
219 |
*/ |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
220 |
public static boolean isOnClassPath(String baseName, ClassLoader cl) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
221 |
ResourceBundle rb = null; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
222 |
try { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
223 |
rb = ResourceBundle.getBundle(baseName, Locale.getDefault(), cl); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
224 |
System.out.println("INFO: Found bundle " + baseName + " on " + cl); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
225 |
} catch (MissingResourceException e) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
226 |
System.out.println("INFO: Could not find bundle " + baseName + " on " + cl); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
227 |
return false; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
228 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
229 |
return (rb != null); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
230 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
231 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
232 |
private static String newLoggerName() { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
233 |
// we need a new logger name every time we attempt to find a bundle via |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
234 |
// the Logger.getLogger call, so we'll simply tack on an integer which |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
235 |
// we increment each time this is called |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
236 |
loggerNum++; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
237 |
return LOGGER_PREFIX + loggerNum; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
238 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
239 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
240 |
public boolean testGetBundleFromSystemClassLoader(String bundleName) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
241 |
// this should succeed if the bundle is on the system classpath. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
242 |
try { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
243 |
Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(), |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
244 |
bundleName); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
245 |
} catch (MissingResourceException re) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
246 |
msgs.add("INFO: testGetBundleFromSystemClassLoader() did not find bundle " |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
247 |
+ bundleName); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
248 |
return false; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
249 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
250 |
msgs.add("INFO: testGetBundleFromSystemClassLoader() found the bundle " |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
251 |
+ bundleName); |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
252 |
return true; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
253 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
254 |
|
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
255 |
private boolean testGetAnonymousLogger() throws Throwable { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
256 |
// This should pass. This exercises getting the bundle using the |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
257 |
// class loader of the caller (one level up) when calling |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
258 |
// Logger.getAnonymousLogger(String rbName) |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
259 |
IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle(); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
260 |
return indirectLoader.testGetAnonymousLogger(); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
261 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
262 |
|
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
263 |
private boolean testGetBundleFromSecondCallersClassLoader() throws Throwable { |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
264 |
// This should pass. This exercises getting the bundle using the |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
265 |
// class loader of the caller (one level up) |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
266 |
IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle(); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
267 |
return indirectLoader.testGetLoggerGetLoggerWithBundle(); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
268 |
} |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
269 |
|
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
270 |
public static class LoggingThread extends Thread { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
271 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
272 |
boolean foundBundle = false; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
273 |
String msg = null; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
274 |
ClassLoader clToSetOnTCCL = null; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
275 |
String bundleName = null; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
276 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
277 |
public LoggingThread(String bundleName) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
278 |
this.bundleName = bundleName; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
279 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
280 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
281 |
public LoggingThread(String bundleName, ClassLoader setOnTCCL) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
282 |
this.clToSetOnTCCL = setOnTCCL; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
283 |
this.bundleName = bundleName; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
284 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
285 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
286 |
public void run() { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
287 |
boolean setTCCL = false; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
288 |
try { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
289 |
if (clToSetOnTCCL != null) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
290 |
Thread.currentThread().setContextClassLoader(clToSetOnTCCL); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
291 |
setTCCL = true; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
292 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
293 |
// this should succeed if the bundle is on the system classpath. |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
294 |
try { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
295 |
Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(), |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
296 |
bundleName); |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
297 |
msg = "INFO: LoggingThread.run() found the bundle " + bundleName |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
298 |
+ (setTCCL ? " with " : " without ") + "setting the TCCL"; |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
299 |
foundBundle = true; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
300 |
} catch (MissingResourceException re) { |
17487
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
301 |
msg = "INFO: LoggingThread.run() did not find the bundle " + bundleName |
77566e5979d1
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
jgish
parents:
17159
diff
changeset
|
302 |
+ (setTCCL ? " with " : " without ") + "setting the TCCL"; |
17159
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
303 |
foundBundle = false; |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
304 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
305 |
} catch (Throwable e) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
306 |
e.printStackTrace(); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
307 |
System.exit(1); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
308 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
309 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
310 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
311 |
|
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
312 |
private void debug(String msg) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
313 |
if (DEBUG) { |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
314 |
System.out.println(msg); |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
315 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
316 |
} |
bb566a21b661
8012005: LogManager needs test to ensure stack trace is not being done to find bundle
jgish
parents:
diff
changeset
|
317 |
} |