Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[JENKINS-9158] Abort warnings parsing if user pressed cancel.
  • Loading branch information
uhafner committed Aug 19, 2011
1 parent 317cd6f commit 826244316931c366efdd3e83d55c54ad1688e72f
Showing with 14 additions and 4 deletions.
  1. +14 −4 src/main/java/hudson/plugins/warnings/WarningsPublisher.java
@@ -229,8 +229,10 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
throw new IOException("Error: No warning parsers defined.");
}

ParserResult project = parseConsoleLog(build, logger);
parseFiles(build, logger, project);
ParserResult project = parseFiles(build, logger);
returnIfCanceled();

parseConsoleLog(build, logger, project);

project = build.getWorkspace().act(new AnnotationsClassifier(project, getDefaultEncoding()));
for (FileAnnotation annotation : project.getAnnotations()) {
@@ -243,7 +245,13 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
return result;
}

private void parseFiles(final AbstractBuild<?, ?> build, final PluginLogger logger,
private void returnIfCanceled() throws InterruptedException {
if (Thread.interrupted()) {
throw new InterruptedException("Canceling parsing since build has been aborted.");
}
}

private void parseConsoleLog(final AbstractBuild<?, ?> build, final PluginLogger logger,
final ParserResult project) throws IOException {
if (!getConsoleLogParsers().isEmpty()) {
logger.log("Parsing warnings in console log with parsers " + getConsoleLogParsers());
@@ -262,7 +270,7 @@ private void parseFiles(final AbstractBuild<?, ?> build, final PluginLogger logg
}
}

private ParserResult parseConsoleLog(final AbstractBuild<?, ?> build, final PluginLogger logger)
private ParserResult parseFiles(final AbstractBuild<?, ?> build, final PluginLogger logger)
throws IOException, InterruptedException {
ParserResult project = new ParserResult(build.getWorkspace());
for (ParserConfiguration configuration : getParserConfigurations()) {
@@ -275,6 +283,8 @@ private ParserResult parseConsoleLog(final AbstractBuild<?, ?> build, final Plug
ParserResult additionalProject = build.getWorkspace().act(parser);
logger.logLines(additionalProject.getLogMessages());
project.addProject(additionalProject);

returnIfCanceled();
}
return project;
}

0 comments on commit 8262443

Please sign in to comment.