The branch, master has been updated
via d106f950fee98979df8f92537f47d5aea361b869 (commit)
from b228e86a5cee41e0617ba04a8350754a011d491a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=d106f950fee98979df8f92537f47d5aea361b869
http://github.com/ceki/logback/commit/d106f950fee98979df8f92537f47d5aea361b869
commit d106f950fee98979df8f92537f47d5aea361b869
Author: Ceki Gulcu <[email protected]>
Date: Tue Dec 1 23:30:17 2009 +0100
Fixed http://jira.qos.ch/browse/LBCORE-122
diff --git
a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
index fc6af03..ffd8528 100644
---
a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
+++
b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
@@ -36,7 +36,6 @@ public class IncludeAction extends Action {
private static final String FILE_ATTR = "file";
private static final String URL_ATTR = "url";
private static final String RESOURCE_ATTR = "resource";
-
private String attributeInUse;
@@ -45,7 +44,7 @@ public class IncludeAction extends Action {
throws ActionException {
SaxEventRecorder recorder = new SaxEventRecorder();
-
+
this.attributeInUse = null;
if (!checkAttributes(attributes)) {
@@ -57,20 +56,27 @@ public class IncludeAction extends Action {
try {
if (in != null) {
parseAndRecord(in, recorder);
- in.close();
}
} catch (JoranException e) {
addError("Error while parsing " + attributeInUse, e);
- } catch (IOException e) {
- // called if in.close did not work
+ } finally {
+ close(in);
}
-
// remove the <included> tag from the beginning and </included> from the
end
trimHeadAndTail(recorder);
-
+
ec.getJoranInterpreter().addEventsDynamically(recorder.saxEventList);
}
+ void close(InputStream in) {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
private boolean checkAttributes(Attributes attributes) {
String fileAttribute = attributes.getValue(FILE_ATTR);
String urlAttribute = attributes.getValue(URL_ATTR);
@@ -170,13 +176,13 @@ public class IncludeAction extends Action {
private void trimHeadAndTail(SaxEventRecorder recorder) {
// Let's remove the two <included> events before
// adding the events to the player.
-
+
List<SaxEvent> saxEventList = recorder.saxEventList;
-
+
if (saxEventList.size() == 0) {
return;
}
-
+
SaxEvent first = saxEventList.get(0);
if (first != null && first.qName.equalsIgnoreCase(INCLUDED_TAG)) {
saxEventList.remove(0);
@@ -188,7 +194,8 @@ public class IncludeAction extends Action {
}
}
- private void parseAndRecord(InputStream inputSource, SaxEventRecorder
recorder) throws JoranException {
+ private void parseAndRecord(InputStream inputSource, SaxEventRecorder
recorder)
+ throws JoranException {
recorder.setContext(context);
recorder.recordEvents(inputSource);
}
diff --git a/logback-core/src/test/input/joran/inclusion/invalid.xml
b/logback-core/src/test/input/joran/inclusion/invalid.xml
index 5eaa0b2..0519ecb 100644
--- a/logback-core/src/test/input/joran/inclusion/invalid.xml
+++ b/logback-core/src/test/input/joran/inclusion/invalid.xml
@@ -1,8 +1 @@
-<included>
- <!-- This file is invalid on purpose. Do not correct it -->
-
- <inc increment="1">
-
- <inc increment="1"/>
-
-</included>
\ No newline at end of file
+
\ No newline at end of file
diff --git
a/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
b/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
index 2979429..c4e1cdf 100644
---
a/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
+++
b/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
@@ -16,7 +16,11 @@ package ch.qos.logback.core.joran.action;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.util.HashMap;
@@ -34,6 +38,8 @@ import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusChecker;
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.StatusPrinter;
public class IncludeActionTest {
@@ -68,6 +74,8 @@ public class IncludeActionTest {
static final String INCLUDED_AS_RESOURCE =
"asResource/joran/inclusion/includedAsResource.xml";
+ int diff = RandomUtil.getPositiveInt();
+
public IncludeActionTest() {
HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
rulesMap.put(new Pattern("x"), new NOPAction());
@@ -106,7 +114,7 @@ public class IncludeActionTest {
verifyConfig(2);
}
- @Test
+ @Test
public void basicURL() throws JoranException {
System.setProperty(INCLUDE_KEY, URL_TO_INCLUDE);
tc.doConfigure(TOP_BY_URL);
@@ -124,14 +132,35 @@ public class IncludeActionTest {
}
@Test
- public void withCorruptFile() throws JoranException {
- System.setProperty(INCLUDE_KEY, INVALID);
+ public void withCorruptFile() throws JoranException, IOException {
+ String tmpOut = copyToTemp(INVALID);
+ System.setProperty(INCLUDE_KEY, tmpOut);
tc.doConfigure(TOP_BY_FILE);
assertEquals(Status.ERROR, context.getStatusManager().getLevel());
StatusChecker sc = new StatusChecker(context.getStatusManager());
assertTrue(sc.containsException(SAXParseException.class));
+
+ // we like to erase the temp file in order to see
+ // if http://jira.qos.ch/browse/LBCORE-122 was fixed
+ File f = new File(tmpOut);
+ assertTrue(f.exists());
+ assertTrue(f.delete());
+
}
+ String copyToTemp(String in) throws IOException {
+ FileInputStream fis = new FileInputStream(in);
+ String out = CoreTestConstants.OUTPUT_DIR_PREFIX+"out"+diff;
+ FileOutputStream fos = new FileOutputStream(out);
+ int b;
+ while((b=fis.read()) != -1) {
+ fos.write(b);
+ }
+ fis.close();
+ fos.close();
+ return out;
+ }
+
@Test
public void malformedURL() throws JoranException {
System.setProperty(INCLUDE_KEY, "htp://logback.qos.ch");
@@ -169,11 +198,18 @@ public class IncludeActionTest {
}
@Test
+ public void saxParseException() throws JoranException {
+ System.setProperty(INCLUDE_KEY, INCLUDED_FILE);
+ System.setProperty(SECOND_FILE_KEY, SECOND_FILE);
+ tc.doConfigure(MULTI_INCLUDE_BY_FILE);
+ verifyConfig(3);
+ }
+
+ @Test
public void errorInDoBegin() {
-
+
}
-
-
+
void verifyConfig(int expected) {
assertEquals(expected, IncAction.beginCount);
assertEquals(expected, IncAction.endCount);
diff --git a/logback-site/src/site/pages/news.html
b/logback-site/src/site/pages/news.html
index 68eb6b0..6dd2dc1 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -48,6 +48,19 @@
as proposed by David Varnes in <a
href="http://jira.qos.ch/browse/LBCORE-101">LBCORE-101</a>.</p>
+ <p><code>ReconfigureOnChangeFilter</code> did not pick up changes
+ for configuration files containing spaces. This issue was reported
+ in <a href="http://jira.qos.ch/browse/LBCORE-119">LBCORE-119</a>
+ by Anders Wallgren.
+ </p>
+
+ <p>When ill-formed configuration files fragments were included in
+ another configuration file, the included file was not closed
+ correctly. This issue was reported in <a
+ href="http://jira.qos.ch/browse/LBCORE-122">LBCORE-122</a> by
+ Michael Franz.
+ </p>
+
<p>JaninoEventEvaluator now passes the throwable associated with
an event as a <code>java.lang.Throwable</code> instead of an
<code>IThrowableProxy</code>. This fixes <a
-----------------------------------------------------------------------
Summary of changes:
.../logback/core/joran/action/IncludeAction.java | 29 +++++++-----
.../src/test/input/joran/inclusion/invalid.xml | 9 +---
.../core/joran/action/IncludeActionTest.java | 48 +++++++++++++++++---
logback-site/src/site/pages/news.html | 13 +++++
4 files changed, 74 insertions(+), 25 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
_______________________________________________
logback-dev mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-dev