diff --git a/src/main/java/edu/hm/hafner/analysis/parser/violations/ValgrindAdapter.java b/src/main/java/edu/hm/hafner/analysis/parser/violations/ValgrindAdapter.java
index aff1130c6..9a04a09e5 100644
--- a/src/main/java/edu/hm/hafner/analysis/parser/violations/ValgrindAdapter.java
+++ b/src/main/java/edu/hm/hafner/analysis/parser/violations/ValgrindAdapter.java
@@ -13,6 +13,9 @@
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.Report;
+import edu.umd.cs.findbugs.annotations.CheckForNull;
+import edu.umd.cs.findbugs.annotations.Nullable;
+
import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.parsers.ValgrindParser;
@@ -23,7 +26,7 @@
*/
public class ValgrindAdapter extends AbstractViolationAdapter {
private static final long serialVersionUID = -6117336551972081612L;
- private static final int numberedStackThreshold = 2;
+ private static final int NUMBERED_STACK_THRESHOLD = 2;
@Override
ValgrindParser createParser() {
@@ -59,7 +62,7 @@ private String generateDescriptionHtml(final Violation violation) {
return description.toString();
}
- private void appendGeneralTable(final StringBuilder html, final String executable, final String uniqueId, final String threadId, final String threadName, final JSONArray auxWhats) {
+ private void appendGeneralTable(final StringBuilder html, final String executable, final String uniqueId, @Nullable final String threadId, @Nullable final String threadName, @Nullable final JSONArray auxWhats) {
html.append("
");
maybeAppendTableRow(html, "Executable", executable);
@@ -76,30 +79,33 @@ private void appendGeneralTable(final StringBuilder html, final String executabl
html.append("
");
}
- private void maybeAppendStackTraces(final StringBuilder html, final String stacksJson, final String message, final JSONArray auxWhats) {
- final JSONArray stacks = new JSONArray(new JSONTokener(stacksJson));
+ private void maybeAppendStackTraces(final StringBuilder html, @Nullable final String stacksJson, final String message, @Nullable final JSONArray auxWhats) {
+ if (stacksJson != null && !stacksJson.isEmpty()) {
+ final JSONArray stacks = new JSONArray(new JSONTokener(stacksJson));
- if (!stacks.isEmpty()) {
- appendStackTrace(html, "Primary Stack Trace", message, stacks.getJSONArray(0));
+ if (!stacks.isEmpty()) {
+ appendStackTrace(html, "Primary Stack Trace", message, stacks.getJSONArray(0));
- for (int stackIndex = 1; stackIndex < stacks.length(); ++stackIndex) {
- String msg = null;
- if (auxWhats != null && auxWhats.length() >= stackIndex) {
- msg = auxWhats.getString(stackIndex - 1);
- }
+ for (int stackIndex = 1; stackIndex < stacks.length(); ++stackIndex) {
+ String msg = null;
- String title = "Auxiliary Stack Trace";
+ if (auxWhats != null && auxWhats.length() >= stackIndex) {
+ msg = auxWhats.getString(stackIndex - 1);
+ }
- if (stacks.length() > numberedStackThreshold) {
- title = "Auxiliary Stack Trace #" + Integer.toString(stackIndex);
- }
+ String title = "Auxiliary Stack Trace";
- appendStackTrace(html, title, msg, stacks.getJSONArray(stackIndex));
+ if (stacks.length() > NUMBERED_STACK_THRESHOLD) {
+ title = "Auxiliary Stack Trace #" + stackIndex;
+ }
+
+ appendStackTrace(html, title, msg, stacks.getJSONArray(stackIndex));
+ }
}
}
}
- private void appendStackTrace(final StringBuilder html, final String title, final String message, final JSONArray frames) {
+ private void appendStackTrace(final StringBuilder html, final String title, @Nullable final String message, final JSONArray frames) {
html
.append("")
.append(title)
@@ -131,7 +137,7 @@ private void appendStackFrame(final StringBuilder html, final JSONObject frame)
html.append("");
}
- private void maybeAppendSuppression(final StringBuilder html, final String suppression) {
+ private void maybeAppendSuppression(final StringBuilder html, @Nullable final String suppression) {
if (suppression != null && !suppression.isEmpty()) {
html
.append("Suppression
")
@@ -140,7 +146,7 @@ private void maybeAppendSuppression(final StringBuilder html, final String suppr
}
}
- private void maybeAppendTableRow(final StringBuilder html, final String name, final String value) {
+ private void maybeAppendTableRow(final StringBuilder html, final String name, @Nullable final String value) {
if (value != null && !value.isEmpty()) {
html
.append("|
|