Skip to content

Commit acf5cc0

Browse files
committed
Fix ConfigurePDXCommandIntegrationTest: Quote parameter values containing '='
Spring Shell 3.x splits parameter values on '=' signs unless they are quoted. Added comprehensive class-level Javadoc explaining why quotes are required and the impact of the GfshParser.splitUserInput() behavior. Changes: - Added 30+ line class-level documentation explaining Spring Shell 3.x parsing - Quoted all --auto-serializable-classes and --portable-auto-serializable-classes parameter values containing '=' (e.g., "com.company.DomainObject.*#identity=id") - Without quotes: parser splits into ["...#identity", "id"] (2 args) - With quotes: parser preserves ["...#identity=id"] (1 arg) This prevents AutoSerializableManager from failing with 'Unable to correctly process auto serialization init value' when it expects 'param=value' format but receives only 'param' due to the split. Tests fixed (4): - commandShouldSucceedWhenConfiguringAutoSerializableClassesWithPersistence - commandShouldSucceedWhenConfiguringAutoSerializableClassesWithoutPersistence - commandShouldSucceedWhenConfiguringPortableAutoSerializableClassesWithPersistence - commandShouldSucceedWhenConfiguringPortableAutoSerializableClassesWithoutPersistence All 6 ConfigurePDXCommandIntegrationTest tests now pass.
1 parent 418bad2 commit acf5cc0

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/ConfigurePDXCommandIntegrationTest.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,36 @@
2525
import org.apache.geode.test.junit.rules.GfshCommandRule;
2626
import org.apache.geode.test.junit.rules.LocatorStarterRule;
2727

28+
/**
29+
* Integration tests for the 'configure pdx' gfsh command.
30+
*
31+
* <p><b>IMPORTANT - Spring Shell 3.x Parameter Quoting:</b></p>
32+
* <p>Parameter values containing '=' signs MUST be quoted to prevent incorrect parsing.
33+
* Spring Shell 3.x's {@link org.apache.geode.management.internal.cli.GfshParser#splitUserInput}
34+
* splits unquoted tokens on '=' by default, treating them as separate arguments.</p>
35+
*
36+
* <p><b>Why Quotes Are Required:</b></p>
37+
* <ul>
38+
* <li><b>Without quotes:</b> {@code --auto-serializable-classes=com.company.DomainObject.*#identity=id}
39+
* <br>Parser sees: {@code ["com.company.DomainObject.*#identity", "id"]} (2 separate values)</li>
40+
* <li><b>With quotes:</b> {@code --auto-serializable-classes="com.company.DomainObject.*#identity=id"}
41+
* <br>Parser sees: {@code ["com.company.DomainObject.*#identity=id"]} (single value)</li>
42+
* </ul>
43+
*
44+
* <p><b>Impact:</b> PDX auto-serialization patterns use the format {@code pattern#param=value}.
45+
* Without quotes, the {@code =value} portion is lost, causing
46+
* {@link org.apache.geode.pdx.internal.AutoSerializableManager} to fail with:
47+
* <pre>"Unable to correctly process auto serialization init value: pattern#param"</pre>
48+
* because it expects {@code param=value} but receives only {@code param}.</p>
49+
*
50+
* <p><b>GfshParser Behavior:</b> The parser explicitly checks for quoted strings and bypasses
51+
* the '=' splitting logic when quotes are detected (see {@code GfshParser.splitUserInput()}).
52+
* This is the intended mechanism for passing parameter values containing delimiter characters.</p>
53+
*
54+
* @see org.apache.geode.management.internal.cli.GfshParser#splitUserInput
55+
* @see org.apache.geode.pdx.ReflectionBasedAutoSerializer
56+
* @see org.apache.geode.pdx.internal.AutoSerializableManager
57+
*/
2858
@Category({ClientServerTest.class})
2959
public class ConfigurePDXCommandIntegrationTest {
3060
private static final String BASE_COMMAND_STRING = "configure pdx ";
@@ -61,7 +91,7 @@ public void commandShouldSucceedWhenUsingDefaults() {
6191
@Test
6292
public void commandShouldSucceedWhenConfiguringAutoSerializableClassesWithPersistence() {
6393
gfsh.executeAndAssertThat(BASE_COMMAND_STRING
64-
+ "--read-serialized=true --disk-store=myDiskStore --ignore-unread-fields=true --auto-serializable-classes=com.company.DomainObject.*#identity=id")
94+
+ "--read-serialized=true --disk-store=myDiskStore --ignore-unread-fields=true --auto-serializable-classes=\"com.company.DomainObject.*#identity=id\"")
6595
.statusIsSuccess();
6696

6797
String sharedConfigXml = locator.getLocator().getConfigurationPersistenceService()
@@ -79,7 +109,7 @@ public void commandShouldSucceedWhenConfiguringAutoSerializableClassesWithPersis
79109
@Test
80110
public void commandShouldSucceedWhenConfiguringAutoSerializableClassesWithoutPersistence() {
81111
gfsh.executeAndAssertThat(BASE_COMMAND_STRING
82-
+ "--read-serialized=false --ignore-unread-fields=false --auto-serializable-classes=com.company.DomainObject.*#identity=id")
112+
+ "--read-serialized=false --ignore-unread-fields=false --auto-serializable-classes=\"com.company.DomainObject.*#identity=id\"")
83113
.statusIsSuccess();
84114

85115
String sharedConfigXml = locator.getLocator().getConfigurationPersistenceService()
@@ -97,7 +127,7 @@ public void commandShouldSucceedWhenConfiguringAutoSerializableClassesWithoutPer
97127
@Test
98128
public void commandShouldSucceedWhenConfiguringPortableAutoSerializableClassesWithPersistence() {
99129
gfsh.executeAndAssertThat(BASE_COMMAND_STRING
100-
+ "--read-serialized=true --disk-store=myDiskStore --ignore-unread-fields=true --portable-auto-serializable-classes=com.company.DomainObject.*#identity=id")
130+
+ "--read-serialized=true --disk-store=myDiskStore --ignore-unread-fields=true --portable-auto-serializable-classes=\"com.company.DomainObject.*#identity=id\"")
101131
.statusIsSuccess();
102132

103133
String sharedConfigXml = locator.getLocator().getConfigurationPersistenceService()
@@ -117,7 +147,7 @@ public void commandShouldSucceedWhenConfiguringPortableAutoSerializableClassesWi
117147
@Test
118148
public void commandShouldSucceedWhenConfiguringPortableAutoSerializableClassesWithoutPersistence() {
119149
gfsh.executeAndAssertThat(BASE_COMMAND_STRING
120-
+ "--read-serialized=false --ignore-unread-fields=false --portable-auto-serializable-classes=com.company.DomainObject.*#identity=id")
150+
+ "--read-serialized=false --ignore-unread-fields=false --portable-auto-serializable-classes=\"com.company.DomainObject.*#identity=id\"")
121151
.statusIsSuccess();
122152

123153
String sharedConfigXml = locator.getLocator().getConfigurationPersistenceService()

0 commit comments

Comments
 (0)