You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@locus.apache.org on 2000/12/21 17:22:07 UTC
cvs commit: jakarta-log4j/org/apache/log4j/test UnitTestCategory.java
ceki 00/12/21 08:22:06
Modified: org/apache/log4j BasicConfigurator.java Category.java
Hierarchy.java PropertyConfigurator.java
StressCategory.java
org/apache/log4j/test UnitTestCategory.java
Log:
Moved the Hiearchy._default variable to Category._default such that the Hiearchy class does no longer
have a static initiliazer. This fixes a very confusing NullPointerException occuring on rare occasions.
Revision Changes Path
1.3 +7 -6 jakarta-log4j/org/apache/log4j/BasicConfigurator.java
Index: BasicConfigurator.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/BasicConfigurator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BasicConfigurator.java 2000/12/14 21:07:16 1.2
+++ BasicConfigurator.java 2000/12/21 16:22:01 1.3
@@ -98,7 +98,7 @@
} else {
try {
Class renderedClass = Class.forName(renderedClassName);
- Hierarchy._default.rendererMap.put(renderedClass, renderer);
+ Category._default.rendererMap.put(renderedClass, renderer);
} catch(ClassNotFoundException e) {
LogLog.error("Could not find class ["+renderedClassName+"].", e);
}
@@ -268,15 +268,16 @@
public
static
void resetConfiguration() {
- Hierarchy._default.getRoot().setPriority(Priority.DEBUG);
- Hierarchy._default.getRoot().removeAllAppenders();
- Hierarchy._default.root.setResourceBundle(null);
+ Category._default.getRoot().setPriority(Priority.DEBUG);
+ Category._default.getRoot().removeAllAppenders();
+ Category._default.root.setResourceBundle(null);
+
Category.disable = Category.DISABLE_OFF;
// the synchronization is needed to prevent JDK 1.2.x hashtable
// surprises
- synchronized(Hierarchy._default.ht) {
+ synchronized(Category._default.ht) {
Enumeration cats = Category.getCurrentCategories();
while(cats.hasMoreElements()) {
Category c = (Category) cats.nextElement();
@@ -286,6 +287,6 @@
c.removeAllAppenders();
}
}
- Hierarchy._default.rendererMap.clear();
+ Category._default.rendererMap.clear();
}
}
1.3 +27 -7 jakarta-log4j/org/apache/log4j/Category.java
Index: Category.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/Category.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Category.java 2000/12/14 21:07:17 1.2
+++ Category.java 2000/12/21 16:22:01 1.3
@@ -65,6 +65,13 @@
static boolean emittedNoAppenderWarning = false;
static boolean emittedNoResourceBundleWarning = false;
+
+ // default is a language reserved term, we exceptionally prefix with
+ // an undescore.
+ static
+ public
+ final Hierarchy _default = new Hierarchy( new RootCategory(Priority.DEBUG));
+
protected ResourceBundle resourceBundle;
@@ -379,7 +386,7 @@
public
static
Category exists(String name) {
- return Hierarchy._default.exists(name);
+ return _default.exists(name);
}
/**
@@ -506,9 +513,9 @@
// The accumlation in v is necessary because not all elements in
// HierarchyMaintainer.ht are Category objects as there might be some
// ProvisionNodes as well.
- Vector v = new Vector(Hierarchy._default.ht.size());
+ Vector v = new Vector(_default.ht.size());
- Enumeration elems = Hierarchy._default.ht.elements();
+ Enumeration elems = _default.ht.elements();
while(elems.hasMoreElements()) {
Object o = elems.nextElement();
if(o instanceof Category) {
@@ -517,6 +524,19 @@
}
return v.elements();
}
+
+
+ /**
+ Return the default Hierarchy instance.
+
+ @since 1.0
+ */
+ public
+ static
+ Hierarchy getDefaultHierarchy() {
+ return _default;
+ }
+
/**
Retrieve a category with named as the <code>name</code>
@@ -532,7 +552,7 @@
public
static
Category getInstance(String name) {
- return Hierarchy._default.getInstance(name);
+ return _default.getInstance(name);
}
/**
@@ -567,7 +587,7 @@
public
static
Category getInstance(String name, CategoryFactory factory) {
- return Hierarchy._default.getInstance(name, factory);
+ return _default.getInstance(name, factory);
}
@@ -605,7 +625,7 @@
public
static
Category getRoot() {
- return Hierarchy._default.getRoot();
+ return _default.getRoot();
}
/**
@@ -958,7 +978,7 @@
public
static
void shutdown() {
- Hierarchy._default.shutdown();
+ _default.shutdown();
}
1.4 +1 -18 jakarta-log4j/org/apache/log4j/Hierarchy.java
Index: Hierarchy.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/Hierarchy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Hierarchy.java 2000/12/19 13:59:19 1.3
+++ Hierarchy.java 2000/12/21 16:22:02 1.4
@@ -46,12 +46,6 @@
*/
public class Hierarchy {
-
- // default is a language reserved term, we exceptionally prefix with
- // an undescore.
- static
- public
- final Hierarchy _default = new Hierarchy(new RootCategory(Priority.DEBUG));
static
private
@@ -185,17 +179,6 @@
/**
- Return the default Hierarchy instance.
-
- @since 0.9.0
- */
- public
- static
- Hierarchy getDefaultHierarchy() {
- return _default;
- }
-
- /**
Get the root of this hierarchy.
@since 0.9.0
@@ -345,7 +328,7 @@
// begin by closing nested appenders
root.closeNestedAppenders();
- synchronized(Hierarchy._default.ht) {
+ synchronized(ht) {
Enumeration cats = Category.getCurrentCategories();
while(cats.hasMoreElements()) {
Category c = (Category) cats.nextElement();
1.3 +1 -1 jakarta-log4j/org/apache/log4j/PropertyConfigurator.java
Index: PropertyConfigurator.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/PropertyConfigurator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PropertyConfigurator.java 2000/12/14 21:07:19 1.2
+++ PropertyConfigurator.java 2000/12/21 16:22:02 1.3
@@ -471,7 +471,7 @@
if(key.startsWith(CATEGORY_PREFIX)) {
String categoryName = key.substring(CATEGORY_PREFIX.length());
String value = OptionConverter.findAndSubst(key, props);
- Category cat = Hierarchy._default.getInstance(categoryName,
+ Category cat = Category._default.getInstance(categoryName,
categoryFactory);
synchronized(cat) {
parseCategory(props, cat, key, categoryName, value);
1.3 +1 -1 jakarta-log4j/org/apache/log4j/StressCategory.java
Index: StressCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/StressCategory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StressCategory.java 2000/12/14 21:07:20 1.2
+++ StressCategory.java 2000/12/21 16:22:02 1.3
@@ -111,7 +111,7 @@
}
test();
// Clear hash table for next round
- Hierarchy._default.clear();
+ Category._default.clear();
}
else {
ct[n] = null;
1.3 +1 -1 jakarta-log4j/org/apache/log4j/test/UnitTestCategory.java
Index: UnitTestCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/test/UnitTestCategory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UnitTestCategory.java 2000/12/14 21:08:14 1.2
+++ UnitTestCategory.java 2000/12/21 16:22:05 1.3
@@ -64,7 +64,7 @@
public
void tearDown() {
// Regular users should not use the clear method lightly!
- Hierarchy.getDefaultHierarchy().clear();
+ Category.getDefaultHierarchy().clear();
BasicConfigurator.resetConfiguration();
a1 = null;
a2 = null;