Skip to content

Commit

Permalink
Bug/fix parser error (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagobcx authored Aug 28, 2024
1 parent 10f98e4 commit c991121
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/com/checkmarx/ast/wrapper/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.slf4j.Logger;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -48,7 +49,9 @@ static <T> T executeCommand(List<String> arguments,
stringBuilder.append(line).append(LINE_SEPARATOR);
T parsedLine = lineParser.apply(line);
if (parsedLine != null) {
executionResult = parsedLine;
if (areAllFieldsNotNull(parsedLine)) {
executionResult = parsedLine;
}
}
}
process.waitFor();
Expand All @@ -59,6 +62,19 @@ static <T> T executeCommand(List<String> arguments,
}
}

private static boolean areAllFieldsNotNull(Object obj) {
for (Field field : obj.getClass().getDeclaredFields()) {
field.setAccessible(true);
try {
if (field.get(obj) == null) {
return false;
}
} catch (IllegalAccessException e) {
return false;
}
}
return true;
}
static String executeCommand(List<String> arguments,
Logger logger,
String directory,
Expand Down

0 comments on commit c991121

Please sign in to comment.