This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 6b2ed7e9078 [fix][cli] Fix pulsar-shell cannot produce message with
quotes and space (#24320)
6b2ed7e9078 is described below
commit 6b2ed7e9078180b70d020414bc07bdcaa192d802
Author: minjian.cai <[email protected]>
AuthorDate: Wed May 21 19:25:14 2025 +0800
[fix][cli] Fix pulsar-shell cannot produce message with quotes and space
(#24320)
---
.../src/main/java/org/apache/pulsar/shell/PulsarShell.java | 3 ++-
.../src/test/java/org/apache/pulsar/shell/PulsarShellTest.java | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git
a/pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java
b/pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java
index 3cc99126fb8..fada8849422 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java
@@ -48,6 +48,7 @@ import org.apache.pulsar.shell.config.FileConfigStore;
import org.jline.console.impl.SystemRegistryImpl;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
+import org.jline.reader.Parser;
import org.jline.reader.impl.DefaultParser;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
@@ -290,7 +291,7 @@ public class PulsarShell {
@Override
public List<String> parseLine(String line) {
- return reader.getParser().parse(line, 0).words();
+ return reader.getParser().parse(line, 0,
Parser.ParseContext.SPLIT_LINE).words();
}
};
}, () -> terminal);
diff --git
a/pulsar-client-tools/src/test/java/org/apache/pulsar/shell/PulsarShellTest.java
b/pulsar-client-tools/src/test/java/org/apache/pulsar/shell/PulsarShellTest.java
index 165fee92378..370db8febe7 100644
---
a/pulsar-client-tools/src/test/java/org/apache/pulsar/shell/PulsarShellTest.java
+++
b/pulsar-client-tools/src/test/java/org/apache/pulsar/shell/PulsarShellTest.java
@@ -42,6 +42,7 @@ import org.apache.pulsar.client.admin.PulsarAdminBuilder;
import org.apache.pulsar.client.admin.Topics;
import org.apache.pulsar.client.cli.CmdProduce;
import org.jline.reader.EndOfFileException;
+import org.jline.reader.Parser;
import org.jline.reader.UserInterruptException;
import org.jline.reader.impl.LineReaderImpl;
import org.jline.terminal.Terminal;
@@ -82,7 +83,7 @@ public class PulsarShellTest {
@Override
public List<String> parseLine(String line) {
- return getParser().parse(line, 0).words();
+ return getParser().parse(line, 0,
Parser.ParseContext.SPLIT_LINE).words();
}
}
@@ -149,11 +150,12 @@ public class PulsarShellTest {
props.setProperty("webServiceUrl", "http://localhost:8080");
linereader.addCmd("admin topics create my-topic --metadata a=b ");
linereader.addCmd("client produce -m msg my-topic");
+ linereader.addCmd("client produce -m \"hello pulsar\" my-topic");
linereader.addCmd("quit");
final TestPulsarShell testPulsarShell = new TestPulsarShell(new
String[]{}, props, pulsarAdmin);
testPulsarShell.run((a) -> linereader, () -> terminal);
verify(topics).createNonPartitionedTopic(eq("persistent://public/default/my-topic"),
any(Map.class));
- verify(testPulsarShell.cmdProduceHolder.get()).call();
+ verify(testPulsarShell.cmdProduceHolder.get(), times(2)).call();
assertEquals((int) testPulsarShell.exitCode, 0);
}