HADOOP-7542. Change Configuration XML format to 1.1 to support for serializing additional characters Contributed by Christopher Egner.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1174562 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1eb7008753
commit
36d7ab3489
@ -26,6 +26,8 @@ Trunk (unreleased changes)
|
||||
HADOOP-7621. alfredo config should be in a file not readable by users
|
||||
(Alejandro Abdelnur via atm)
|
||||
|
||||
HADOOP-7542. Change Configuration XML format to 1.1 to support for serializing additional characters (Christopher Egner via harsh)
|
||||
|
||||
Release 0.23.0 - Unreleased
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -1632,6 +1632,10 @@ private synchronized Document asXmlDocument() throws IOException {
|
||||
try {
|
||||
doc =
|
||||
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||
|
||||
// Allow a broader set of control characters to appear in job confs.
|
||||
// cf https://issues.apache.org/jira/browse/MAPREDUCE-109
|
||||
doc.setXmlVersion( "1.1" );
|
||||
} catch (ParserConfigurationException pe) {
|
||||
throw new IOException(pe);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ protected void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
private void startConfig() throws IOException{
|
||||
out.write("<?xml version=\"1.0\"?>\n");
|
||||
out.write("<?xml version=\"1.1\"?>\n");
|
||||
out.write("<configuration>\n");
|
||||
}
|
||||
|
||||
@ -221,6 +221,18 @@ public void testCommentsInValue() throws IOException {
|
||||
assertEquals("this contains a comment", conf.get("my.comment"));
|
||||
}
|
||||
|
||||
public void testControlAInValue() throws IOException {
|
||||
out = new BufferedWriter(new FileWriter(CONFIG));
|
||||
startConfig();
|
||||
appendProperty("my.char", "");
|
||||
appendProperty("my.string", "somestring");
|
||||
endConfig();
|
||||
Path fileResource = new Path(CONFIG);
|
||||
conf.addResource(fileResource);
|
||||
assertEquals("\u0001", conf.get("my.char"));
|
||||
assertEquals("some\u0001string", conf.get("my.string"));
|
||||
}
|
||||
|
||||
public void testTrim() throws IOException {
|
||||
out=new BufferedWriter(new FileWriter(CONFIG));
|
||||
startConfig();
|
||||
@ -298,7 +310,7 @@ public void testWriteXml() throws IOException {
|
||||
conf.writeXml(baos);
|
||||
String result = baos.toString();
|
||||
assertTrue("Result has proper header", result.startsWith(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><configuration>"));
|
||||
"<?xml version=\"1.1\" encoding=\"UTF-8\" standalone=\"no\"?><configuration>"));
|
||||
assertTrue("Result has proper footer", result.endsWith("</configuration>"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user