Skip to content

Commit 3eea82c

Browse files
committed
revert
1 parent fb46e6c commit 3eea82c

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

commands/source_mcp/source_mcp.go

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package source_mcp
22

33
import (
4-
"errors"
54
"fmt"
65
"io"
76
"os/exec"
@@ -29,35 +28,25 @@ type McpCommand struct {
2928
}
3029

3130
func establishPipeToFile(dst io.WriteCloser, src io.Reader) {
32-
defer func() {
33-
err := dst.Close()
34-
if err != nil {
35-
log.Error("Error closing destination pipe")
36-
}
37-
}()
31+
defer dst.Close()
3832
_, err := io.Copy(dst, src)
3933
if err != nil {
4034
log.Error("Error establishing pipe")
4135
}
4236
}
4337

4438
func establishPipeFromFile(dst io.Writer, src io.ReadCloser) {
45-
defer func() {
46-
err := src.Close()
47-
if err != nil {
48-
log.Error("Error closing source pipe")
49-
}
50-
}()
39+
defer src.Close()
5140
_, err := io.Copy(dst, src)
5241
if err != nil {
5342
log.Error("Error establishing pipe")
5443
}
5544
}
5645

57-
func RunAmMcpWithPipes(env map[string]string, cmd string, input_pipe io.Reader, output_pipe io.Writer, error_pipe io.Writer, timeout int, args ...string) (err error) {
46+
func RunAmMcpWithPipes(env map[string]string, cmd string, input_pipe io.Reader, output_pipe io.Writer, error_pipe io.Writer, timeout int, args ...string) error {
5847
am_path, err := jas.GetAnalyzerManagerExecutable()
5948
if err != nil {
60-
return
49+
return err
6150
}
6251

6352
allArgs := append([]string{cmd}, args...)
@@ -70,33 +59,21 @@ func RunAmMcpWithPipes(env map[string]string, cmd string, input_pipe io.Reader,
7059
log.Error(fmt.Sprintf("Error creating MCPService stdin pipe: %v", _error))
7160
return _error
7261
}
73-
defer func() {
74-
if _error := stdin.Close(); _error != nil {
75-
err = errors.Join(err, fmt.Errorf("error closing MCPService stdin pipe: %v", _error))
76-
}
77-
}()
62+
defer stdin.Close()
7863

7964
stdout, _error := command.StdoutPipe()
8065
if _error != nil {
8166
log.Error(fmt.Sprintf("Error creating MCPService stdout pipe: %v", _error))
8267
return _error
8368
}
84-
defer func() {
85-
if _error := stdout.Close(); _error != nil {
86-
err = errors.Join(err, fmt.Errorf("error closing MCPService stdout pipe: %v", _error))
87-
}
88-
}()
69+
defer stdout.Close()
8970

9071
stderr, _error := command.StderrPipe()
9172
if _error != nil {
9273
log.Error(fmt.Sprintf("Error creating MCPService stderr pipe: %v", _error))
9374
return _error
9475
}
95-
defer func() {
96-
if _error := stderr.Close(); _error != nil {
97-
err = errors.Join(err, fmt.Errorf("error closing MCPService stderr pipe: %v", _error))
98-
}
99-
}()
76+
defer stderr.Close()
10077

10178
go establishPipeToFile(stdin, input_pipe)
10279
go establishPipeFromFile(error_pipe, stderr)

0 commit comments

Comments
 (0)