From 8f341c673f4db981544faba79d0c20bfe9c3fd99 Mon Sep 17 00:00:00 2001 From: Erik Krogen Date: Wed, 18 Apr 2018 14:38:23 +0900 Subject: [PATCH] HDFS-12828. OIV ReverseXML Processor fails with escaped characters Signed-off-by: Akira Ajisaka (cherry picked from commit 2d9e791a9073de9f65fef5407efd3a42894bc97f) --- .../offlineImageViewer/OfflineImageReconstructor.java | 4 ++-- .../tools/offlineImageViewer/TestOfflineImageViewer.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java index 1f629b24448..d14c61b8f1f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java @@ -380,8 +380,8 @@ class OfflineImageReconstructor { break; case XMLEvent.CHARACTERS: String val = XMLUtils. - unmangleXmlString(ev.asCharacters().getData(), true); - parent.setVal(val); + unmangleXmlString(ev.asCharacters().getData(), false); + parent.setVal(parent.getVal() + val); events.nextEvent(); break; case XMLEvent.ATTRIBUTE: diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java index 74e426e6b9e..d0a7567c2ff 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java @@ -153,10 +153,15 @@ public class TestOfflineImageViewer { dirCount++; writtenFiles.put(emptydir.toString(), hdfs.getFileStatus(emptydir)); - //Create a directory whose name should be escaped in XML + //Create directories whose name should be escaped in XML Path invalidXMLDir = new Path("/dirContainingInvalidXMLChar\u0000here"); hdfs.mkdirs(invalidXMLDir); dirCount++; + Path entityRefXMLDir = new Path("/dirContainingEntityRef&here"); + hdfs.mkdirs(entityRefXMLDir); + dirCount++; + writtenFiles.put(entityRefXMLDir.toString(), + hdfs.getFileStatus(entityRefXMLDir)); //Create a directory with sticky bits Path stickyBitDir = new Path("/stickyBit");