Skip to content

Commit

Permalink
Prevent NPE when original source content is missing
Browse files Browse the repository at this point in the history
Closes #3234

Closes #3235.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=234675335
  • Loading branch information
ChadKillingsworth authored and lauraharker committed Feb 21, 2019
1 parent cdc0915 commit d32ddbb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/com/google/debugging/sourcemap/SourceMapGeneratorV3.java
Expand Up @@ -17,6 +17,7 @@
package com.google.debugging.sourcemap;

import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.nullToEmpty;

import com.google.common.base.Preconditions;
import com.google.debugging.sourcemap.SourceMapConsumerV3.EntryVisitor;
Expand All @@ -29,6 +30,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -508,7 +510,8 @@ private void addSourcesContentMap(Appendable out) throws IOException {
if (i != 0) {
out.append(",");
}
out.append(escapeString(contents.get(i)));
String sourceContent = contents.get(i);
out.append(escapeString(nullToEmpty(sourceContent)));
}
out.append("]");
appendFieldEnd(out);
Expand Down Expand Up @@ -856,7 +859,7 @@ private static void appendOffsetValue(Appendable out, int line, int column) thro
}

private int getSourceId(String sourceName) {
if (sourceName != lastSourceFile) {
if (!Objects.equals(sourceName, lastSourceFile)) {
lastSourceFile = sourceName;
Integer index = sourceFileMap.get(sourceName);
if (index != null) {
Expand Down

0 comments on commit d32ddbb

Please sign in to comment.