Skip to content

Commit c991121

Browse files
authored
Bug/fix parser error (#361)
1 parent 10f98e4 commit c991121

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/main/java/com/checkmarx/ast/wrapper/Execution.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.slf4j.Logger;
44
import java.io.*;
5+
import java.lang.reflect.Field;
56
import java.net.URL;
67
import java.nio.charset.StandardCharsets;
78
import java.nio.file.Files;
@@ -48,7 +49,9 @@ static <T> T executeCommand(List<String> arguments,
4849
stringBuilder.append(line).append(LINE_SEPARATOR);
4950
T parsedLine = lineParser.apply(line);
5051
if (parsedLine != null) {
51-
executionResult = parsedLine;
52+
if (areAllFieldsNotNull(parsedLine)) {
53+
executionResult = parsedLine;
54+
}
5255
}
5356
}
5457
process.waitFor();
@@ -59,6 +62,19 @@ static <T> T executeCommand(List<String> arguments,
5962
}
6063
}
6164

65+
private static boolean areAllFieldsNotNull(Object obj) {
66+
for (Field field : obj.getClass().getDeclaredFields()) {
67+
field.setAccessible(true);
68+
try {
69+
if (field.get(obj) == null) {
70+
return false;
71+
}
72+
} catch (IllegalAccessException e) {
73+
return false;
74+
}
75+
}
76+
return true;
77+
}
6278
static String executeCommand(List<String> arguments,
6379
Logger logger,
6480
String directory,

0 commit comments

Comments
 (0)