Copilot commented on code in PR #726:
URL: 
https://github.com/apache/incubator-seata-samples/pull/726#discussion_r2813250094


##########
e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java:
##########
@@ -57,6 +57,13 @@ public void runE2ETests() {
         File e2eDir = new File(this.e2eDir);
         List<String> passedProjects = new ArrayList<>();
         File[] files = e2eDir.listFiles();

Review Comment:
   The local variable `File e2eDir = new File(this.e2eDir);` shadows the 
`e2eDir` field name; with the added error handling it’s now easy to confuse 
`this.e2eDir` (String) vs `e2eDir` (File). Renaming the local variable (e.g., 
`e2eDirFile`) would make this block clearer.
   ```suggestion
           File e2eDirFile = new File(this.e2eDir);
           List<String> passedProjects = new ArrayList<>();
           File[] files = e2eDirFile.listFiles();
   ```



##########
e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java:
##########
@@ -57,6 +57,13 @@ public void runE2ETests() {
         File e2eDir = new File(this.e2eDir);
         List<String> passedProjects = new ArrayList<>();
         File[] files = e2eDir.listFiles();
+        if (files == null) {
+            LOGGER.error("Failed to list files in directory: " + this.e2eDir);
+            LOGGER.error("Please check if the directory exists and is 
accessible.");

Review Comment:
   `File.listFiles()` returns null for multiple reasons (path doesn’t exist, 
not a directory, I/O/permission issues). Consider checking `e2eDir.exists()` / 
`e2eDir.isDirectory()` and logging the absolute path + those flags so failures 
are easier to diagnose.



##########
e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java:
##########
@@ -57,6 +57,13 @@ public void runE2ETests() {
         File e2eDir = new File(this.e2eDir);
         List<String> passedProjects = new ArrayList<>();
         File[] files = e2eDir.listFiles();
+        if (files == null) {
+            LOGGER.error("Failed to list files in directory: " + this.e2eDir);
+            LOGGER.error("Please check if the directory exists and is 
accessible.");

Review Comment:
   These new log lines use string concatenation; elsewhere in this file SLF4J 
parameterized logging is used (e.g., `LOGGER.error("Test Directory: {}", 
...)`). Prefer `{}` placeholders here as well to avoid unnecessary string 
building and keep logging consistent.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to