GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix for MJAVADOC-793 · codehaus-plexus/plexus-xml@b2263d5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • main/java/org/codehaus/plexus/util/xml/pull
      • MXSerializer.java
    • test/java/org/codehaus/plexus/util/xml/pull
      • MXSerializerTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,9 @@ public void flush() throws IOException {
854854
// --- utility methods
855855

856856
protected void writeAttributeValue(String value, Writer out) throws IOException {
857+
if (value == null) {
858+
return;
859+
}
857860
// .[apostrophe and <, & escaped],
858861
final char quot = attributeUseApostrophe ? '\'' : '"';
859862
final String quotEntity = attributeUseApostrophe ? "&apos;" : "&quot;";
@@ -908,6 +911,9 @@ protected void writeAttributeValue(String value, Writer out) throws IOException
908911
}
909912

910913
protected void writeElementContent(String text, Writer out) throws IOException {
914+
if (text == null) {
915+
return;
916+
}
911917
// escape '<', '&', ']]>', <32 if necessary
912918
int pos = 0;
913919
for (int i = 0; i < text.length(); i++) {
Collapse file

‎src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.codehaus.plexus.util.xml.pull;
22

3+
import java.io.IOException;
34
import java.io.StringReader;
45
import java.io.StringWriter;
56
import java.util.Arrays;
@@ -55,4 +56,19 @@ private String expectedOutput() {
5556
out.append("</root>");
5657
return out.toString();
5758
}
59+
60+
/**
61+
* Tests MJAVADOC-793.
62+
*/
63+
@Test
64+
public void testMJAVADOC793() throws IOException {
65+
// should be no-ops
66+
new MXSerializer().writeElementContent(null, null);
67+
new MXSerializer().writeAttributeValue(null, null);
68+
final StringWriter stringWriter = new StringWriter();
69+
new MXSerializer().writeElementContent(null, stringWriter);
70+
assertEquals("", stringWriter.toString());
71+
new MXSerializer().writeAttributeValue(null, stringWriter);
72+
assertEquals("", stringWriter.toString());
73+
}
5874
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.