sdeboy 2004/05/23 00:46:43
Modified: src/java/org/apache/log4j/xml UtilLoggingXMLDecoder.java
XMLDecoder.java UtilLoggingEntityResolver.java
src/java/org/apache/log4j/chainsaw/help release-notes.html
Log:
Updated XML decoders to parse files in pieces instead of attempting to parse the
entire file in one parse - in order to avoid out of memory errors when loading large
XML files
The conversion of xml to events will use as much processor as possible and may take
some time to finish prior to loading events in the application (no visual feedback
that the conversion process is ongoing) - discovered by Stephen Pain
NOTE: XML Decoders need rewritten using sax
Revision Changes Path
1.14 +16 -35
logging-log4j/src/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java
Index: UtilLoggingXMLDecoder.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/xml/UtilLoggingXMLDecoder.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- UtilLoggingXMLDecoder.java 22 May 2004 01:17:01 -0000 1.13
+++ UtilLoggingXMLDecoder.java 23 May 2004 07:46:43 -0000 1.14
@@ -136,25 +136,24 @@
}
/**
- * Reads the contents of the file into a String
- * @param file the file to load
- * @return The contents of the file as a String
- * @throws IOException if an error occurred during the loading process
+ * Decodes a File into a Vector of LoggingEvents
+ * @param file the file to decode events from
+ * @return Vector of LoggingEvents
+ * @throws IOException
*/
- private String loadFileSource(URL url) throws IOException {
- LineNumberReader reader = null;
- StringBuffer buf = new StringBuffer(1024);
+ public Vector decode(URL url) throws IOException {
+ LineNumberReader reader = new LineNumberReader(new
InputStreamReader(url.openStream()));
+ Vector v = new Vector();
+ String line = null;
try {
- reader = new LineNumberReader(new InputStreamReader(url.openStream()));
-
- String line = null;
-
- while ((line = reader.readLine()) != null) {
- buf.append(line);
- }
- } catch (IOException e) {
- throw e;
+ while ((line = reader.readLine()) != null) {
+ StringBuffer buffer = new StringBuffer(line);
+ for (int i = 0;i<100;i++) {
+ buffer.append(reader.readLine());
+ }
+ v.addAll(decodeEvents(buffer.toString()));
+ }
} finally {
try {
if (reader != null) {
@@ -164,25 +163,7 @@
e.printStackTrace();
}
}
-
- return buf.toString();
- }
-
- /**
- * Decodes a File into a Vector of LoggingEvents
- * @param file the file to decode events from
- * @return Vector of LoggingEvents
- * @throws IOException
- */
- public Vector decode(URL url) throws IOException {
- String fileContents = loadFileSource(url);
- Document doc = parse(fileContents);
-
- if (doc == null) {
- return null;
- }
-
- return decodeEvents(doc);
+ return v;
}
/**
1.17 +16 -35 logging-log4j/src/java/org/apache/log4j/xml/XMLDecoder.java
Index: XMLDecoder.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/xml/XMLDecoder.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XMLDecoder.java 22 May 2004 01:17:01 -0000 1.16
+++ XMLDecoder.java 23 May 2004 07:46:43 -0000 1.17
@@ -101,7 +101,6 @@
if (docBuilder == null || data == null) {
return null;
}
-
Document document = null;
try {
@@ -133,25 +132,24 @@
}
/**
- * Reads the contents of the file into a String
- * @param file the file to load
- * @return The contents of the file as a String
- * @throws IOException if an error occurred during the loading process
+ * Decodes a File into a Vector of LoggingEvents
+ * @param file the file to decode events from
+ * @return Vector of LoggingEvents
+ * @throws IOException
*/
- private String loadFileSource(URL url) throws IOException {
- LineNumberReader reader = null;
- StringBuffer buf = new StringBuffer(1024);
+ public Vector decode(URL url) throws IOException {
+ LineNumberReader reader = new LineNumberReader(new
InputStreamReader(url.openStream()));
+ Vector v = new Vector();
+ String line = null;
try {
- reader = new LineNumberReader(new InputStreamReader(url.openStream()));
-
- String line = null;
-
- while ((line = reader.readLine()) != null) {
- buf.append(line);
- }
- } catch (IOException e) {
- throw e;
+ while ((line = reader.readLine()) != null) {
+ StringBuffer buffer = new StringBuffer(line);
+ for (int i = 0;i<100;i++) {
+ buffer.append(reader.readLine());
+ }
+ v.addAll(decodeEvents(buffer.toString()));
+ }
} finally {
try {
if (reader != null) {
@@ -161,24 +159,7 @@
e.printStackTrace();
}
}
-
- return buf.toString();
- }
-
- /**
- * Decodes a File into a Vector of LoggingEvents
- * @param file the file to decode events from
- * @return Vector of LoggingEvents
- * @throws IOException
- */
- public Vector decode(URL url) throws IOException {
- String fileContents = loadFileSource(url);
- Document doc = parse(fileContents);
-
- if (doc == null) {
- return null;
- }
- return decodeEvents(fileContents);
+ return v;
}
public Vector decodeEvents(String document) {
1.3 +0 -2
logging-log4j/src/java/org/apache/log4j/xml/UtilLoggingEntityResolver.java
Index: UtilLoggingEntityResolver.java
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/xml/UtilLoggingEntityResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UtilLoggingEntityResolver.java 27 Feb 2004 16:47:35 -0000 1.2
+++ UtilLoggingEntityResolver.java 23 May 2004 07:46:43 -0000 1.3
@@ -35,8 +35,6 @@
public class UtilLoggingEntityResolver implements EntityResolver {
public InputSource resolveEntity (String publicId, String systemId) {
- System.err.println("publicID: ["+publicId+"]");
- System.err.println("systemId: ["+systemId+"]");
if (systemId.endsWith("logger.dtd")) {
Class clazz = getClass();
InputStream in =
clazz.getResourceAsStream("/org/apache/log4j/xml/logger.dtd");
1.11 +1 -0
logging-log4j/src/java/org/apache/log4j/chainsaw/help/release-notes.html
Index: release-notes.html
===================================================================
RCS file:
/home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/help/release-notes.html,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- release-notes.html 22 May 2004 05:55:02 -0000 1.10
+++ release-notes.html 23 May 2004 07:46:43 -0000 1.11
@@ -16,6 +16,7 @@
<li>Events loaded from an XML-formatted file are now processed like other events
(throttled based on responsiveness setting and conforming to cyclic buffer limits) -
discovered by Stephen Pain.</li>
<li>Changed how 'scroll to bottom' is activated and deactivated. Now, scrolling
occurs only if 'scroll to bottom' is selected in the context menu AND the last row is
selected. To deactivate scrolling, select a row other than last row. To re-activate
scrolling, press ctrl-end to select the last row. (Scrolling is bypassed in two
cases: a find is active, or when the bottom row is not selected as described above.)
Scrolling enhancement suggested by Hani.</li>
<li>Removed jdk1.4-specific code - Chainsaw can now be ran on JDK1.3 or greater</li>
+<li>Updated XML decoders to handle the processing of large files in a way that
prevents out of memory errors. The conversion of xml to events will use as much
processor as possible and may take some time to finish prior to loading events in the
application (no visual feedback that the conversion process is ongoing) - discovered
by Stephen Pain.</li>
</ul>
<h2>20 May 2004</h2>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]