Skip to content

Commit

Permalink
[JENKINS-37664] Do not even try to copy logs past the end.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Aug 24, 2016
1 parent 6e3d7f4 commit 79a5283
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java
Expand Up @@ -380,13 +380,13 @@ private void copyLogs() {
}

try {
long revised = logText.writeRawLogTo(old, logger);
long revised = writeRawLogTo(logText, old, logger);
if (revised != old) {
logsToCopy.put(id, revised);
modified = true;
}
if (logText.isComplete()) {
logText.writeRawLogTo(revised, logger); // defend against race condition?
writeRawLogTo(logText, revised, logger); // defend against race condition?
assert !node.isRunning() : "LargeText.complete yet " + node + " claims to still be running";
logsToCopy.remove(id);
modified = true;
Expand Down Expand Up @@ -414,6 +414,15 @@ private void copyLogs() {
}
}
}
private long writeRawLogTo(AnnotatedLargeText<?> text, long start, OutputStream out) throws IOException {
long len = text.length();
if (start > len) {
LOGGER.log(Level.WARNING, "JENKINS-37664: attempt to copy logs in {0} @{1} past end @{2}", new Object[] {this, start, len});
return len;
} else {
return text.writeRawLogTo(start, out);
}
}

@GuardedBy("completed")
private transient LoadingCache<FlowNode,Optional<String>> logPrefixCache;
Expand Down

0 comments on commit 79a5283

Please sign in to comment.