Skip to content

Commit 248e83d

Browse files
committed
Fix jcmd file handling #43
1 parent 9612a23 commit 248e83d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cf_cli_java_plugin.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,13 @@ fi`,
225225
SshCommand: FilterJCMDRemoteMessage + `$JCMD_COMMAND $(pidof java) VM.info | filter_jcmd_remote_message`,
226226
},
227227
{
228-
Name: "jcmd",
229-
Description: "Run a JCMD command on a running Java application via --args, downloads and deletes all files that are created in the current folder, use '--no-download' to prevent this",
230-
RequiredTools: []string{"jcmd"},
231-
GenerateFiles: false,
232-
SshCommand: `$JCMD_COMMAND $(pidof java) $$ARGS`,
228+
Name: "jcmd",
229+
Description: "Run a JCMD command on a running Java application via --args, downloads and deletes all files that are created in the current folder, use '--no-download' to prevent this",
230+
RequiredTools: []string{"jcmd"},
231+
GenerateFiles: false,
232+
GenerateArbitraryFiles: true,
233+
GenerateArbitraryFilesFolderName: "jcmd",
234+
SshCommand: `$JCMD_COMMAND $(pidof java) $$ARGS`,
233235
},
234236
{
235237
Name: "jfr-start",
@@ -687,9 +689,13 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
687689
}
688690
}
689691
if command.GenerateArbitraryFiles && !noDownload {
690-
logVerbose("Processing arbitrary files download")
692+
logVerbose(fmt.Sprintf("Processing arbitrary files download: %s", fspath))
693+
logVerbose(fmt.Sprintf("cfSSHArguments: %v", cfSSHArguments))
691694
// download all files in the generic folder
692695
files, err := util.ListFiles(cfSSHArguments, fspath)
696+
for i, file := range files {
697+
logVerbose(fmt.Sprintf("File %d: %s", i+1, file))
698+
}
693699
if err != nil {
694700
logVerbose(fmt.Sprintf("Failed to list files: %v", err))
695701
return "", err

utils/cfutils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ func (checker CfJavaPluginUtilImpl) GetAvailablePath(data string, userpath strin
187187
}
188188

189189
func (checker CfJavaPluginUtilImpl) CopyOverCat(args []string, src string, dest string) error {
190+
fmt.Println("Copying file from remote to local: ", src, " to ", dest)
191+
fmt.Println("Args used: ", args)
190192
f, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
191193
if err != nil {
192194
return errors.New("Error creating local file at " + dest + ". Please check that you are allowed to create files at the given local path.")

0 commit comments

Comments
 (0)