Skip to content

Commit

Permalink
👻 only decompile when directory doesnt exist (#336)
Browse files Browse the repository at this point in the history
Since we moved the decompilation into filter.go, we are now decompiling
prior to filtering the incidents out. In that case, for files with
.groovy, .kotlin etc, we are decompiling unnecessarily multiple times
without knowing that we are anyway going to fail getting incidents from
them later on. This was causing some shim tests to take awful lot of
time.

Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad authored Sep 18, 2023
1 parent 075510c commit b9bce95
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion provider/internal/java/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ func (p *javaServiceClient) getURI(refURI string) (uri.URI, error) {

javaFileAbsolutePath := filepath.Join(filepath.Dir(jarPath), filepath.Dir(path), javaFileName)

if _, err := os.Stat(javaFileAbsolutePath); err != nil {
// attempt to decompile when directory for the expected java file doesn't exist
// if directory exists, assume .java file is present within, this avoids decompiling every Jar
if _, err := os.Stat(filepath.Dir(javaFileAbsolutePath)); err != nil {
cmd := exec.Command("jar", "xf", filepath.Base(jarPath))
cmd.Dir = filepath.Dir(jarPath)
err := cmd.Run()
Expand Down

0 comments on commit b9bce95

Please sign in to comment.