This is an automated email from the ASF dual-hosted git repository.
heliang666s pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new 9b32dc11eb Fix environment-dependent flakiness in XmlSafetyTest by
restricting process comparison to child sleep commands (#15776)
9b32dc11eb is described below
commit 9b32dc11eb3f2bd080f2b6e87591caba2ece0468
Author: Anshul Bisht <[email protected]>
AuthorDate: Fri Nov 21 02:28:43 2025 -0600
Fix environment-dependent flakiness in XmlSafetyTest by restricting process
comparison to child sleep commands (#15776)
---
.../http12/message/codec/XmlSafetyTest.java | 37 ++++++++++++++++++++--
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git
a/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/codec/XmlSafetyTest.java
b/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/codec/XmlSafetyTest.java
index bc5188ab5f..100cb2e311 100644
---
a/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/codec/XmlSafetyTest.java
+++
b/dubbo-remoting/dubbo-remoting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/codec/XmlSafetyTest.java
@@ -82,15 +82,41 @@ public class XmlSafetyTest {
static class ProcessChecker {
Set<String> processesBefore;
+ String currentPid;
public Set<String> getProcesses() {
+ if (currentPid == null) {
+ return Collections.emptySet();
+ }
try {
Set<String> processes = new HashSet<>();
- Process process = Runtime.getRuntime().exec("ps -e");
+ Process process = Runtime.getRuntime().exec(new String[]
{"ps", "-o", "pid,ppid,cmd"});
try (BufferedReader reader = new BufferedReader(new
InputStreamReader(process.getInputStream()))) {
String line;
+ boolean headerSkipped = false;
while ((line = reader.readLine()) != null) {
- processes.add(line);
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue;
+ }
+
+ if (!headerSkipped) {
+ headerSkipped = true;
+ continue;
+ }
+
+ String[] parts = line.split("\\s+", 3);
+ if (parts.length < 3) {
+ continue;
+ }
+
+ String pid = parts[0];
+ String ppid = parts[1];
+ String cmd = parts[2];
+
+ if (ppid.equals(currentPid) && cmd.contains("sleep")
&& cmd.contains("60")) {
+ processes.add(pid + ":" + cmd);
+ }
}
}
return processes;
@@ -100,13 +126,18 @@ public class XmlSafetyTest {
}
public void prepare() {
+ try {
+ currentPid = new
File("/proc/self").getCanonicalFile().getName();
+ } catch (IOException e) {
+ currentPid = null;
+ }
processesBefore = getProcesses();
}
public void check() throws Exception {
Set<String> processesAfter = getProcesses();
for (String msg : processesAfter) {
- if (msg.contains("sleep")) {
+ if (!processesBefore.contains(msg)) {
throw new Exception("Command executed when XML
deserialization.");
}
}