Skip to content

Commit 317755b

Browse files
committed
Fix to cut extra elements from Java 11 serialization
1 parent d8a7afe commit 317755b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/ConfigurationHelp.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ public static String getSamples() throws RuntimeException {
9292
mthd);
9393
}
9494

95+
String propertyName = mthd.getName().replaceFirst("^set", "");
96+
9597
sample = conf.getXMLRepresentationAsString();
9698
sample = sample.replaceFirst(
9799
"(?sx)^<\\?xml.*Configuration\\d*\">\\n", "");
98100
sample = sample.replaceFirst("</object>\\n</java>", "");
101+
// With Java 11 the following excision is necessary.
102+
sample = sample.replaceFirst("(?isx)^.*\\n(?=\\s*<void\\s+property=\"" +
103+
propertyName + "\")", "");
99104

100105
h.clear();
101106
h.append(XML_COMMENT_START);

opengrok-indexer/src/test/java/org/opengrok/indexer/configuration/ConfigurationHelpTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2018, Chris Fraire <[email protected]>.
21+
* Copyright (c) 2018, 2020, Chris Fraire <[email protected]>.
2222
*/
2323

2424
package org.opengrok.indexer.configuration;
2525

26+
import static org.junit.Assert.assertFalse;
2627
import static org.junit.Assert.assertTrue;
2728
import org.junit.Test;
2829

@@ -33,9 +34,12 @@ public class ConfigurationHelpTest {
3334
@Test
3435
public void shouldCreateReadableUsage() {
3536
String samples = ConfigurationHelp.getSamples();
36-
assertTrue("samples are not empty", !samples.isEmpty());
37+
assertFalse("samples are not empty", samples.isEmpty());
3738
assertTrue("samples contains \"<?\"", samples.contains("<?"));
3839
assertTrue("samples contains \"user-defined\"",
3940
samples.contains("user-defined"));
41+
assertTrue("Java 11 nulls are removed",
42+
samples.contains("<!-- Sample for setWebappCtags. Default is false -->\n" +
43+
" <void property=\"webappCtags\">\n"));
4044
}
4145
}

0 commit comments

Comments
 (0)