rshamunov commented on code in PR #25032:
URL: https://github.com/apache/beam/pull/25032#discussion_r1088926343


##########
playground/backend/internal/fs_tool/java_fs.go:
##########
@@ -52,27 +56,53 @@ func executableName(executableFileFolderPath string) 
(string, error) {
        }
 
        if len(dirEntries) == 1 {
-               return strings.Split(dirEntries[0].Name(), ".")[0], nil
+               return utils.TrimExtension(dirEntries[0].Name()), nil
        }
 
        for _, entry := range dirEntries {
-               content, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", 
executableFileFolderPath, entry.Name()))
+               filePath := fmt.Sprintf("%s/%s", executableFileFolderPath, 
entry.Name())
+               content, err := os.ReadFile(filePath)
                if err != nil {
                        logger.Error(fmt.Sprintf("error during file reading: 
%s", err.Error()))
                        break
                }
-               ext := strings.Split(entry.Name(), ".")[1]
-               sdk := utils.ToSDKFromExt("." + ext)
+               ext := filepath.Ext(entry.Name())
+               filename := strings.TrimSuffix(entry.Name(), ext)
+               sdk := utils.ToSDKFromExt(ext)
 
                if sdk == pb.Sdk_SDK_UNSPECIFIED {
-                       logger.Error("invalid a file extension")
+                       logger.Error("invalid file extension")
                        break
                }
 
-               if utils.IsFileMain(string(content), sdk) {
-                       return strings.Split(entry.Name(), ".")[0], nil
+               switch ext {
+               case javaCompiledFileExtension:
+                       isMain, err := isMainClass(executableFileFolderPath, 
filename)
+                       if err != nil {
+                               return "", err
+                       }
+                       if isMain {
+                               return filename, nil

Review Comment:
   Current logic looks correct



-- 
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]

Reply via email to