Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #729 from vjuranek/fix_pull646
[FIXED JENKINS-17084] Changelog should produce output even if some chang...
  • Loading branch information
vjuranek committed Mar 22, 2013
2 parents 8ef261e + 0c46701 commit 4a39c5a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/java/hudson/scm/ChangeLogSet.java
Expand Up @@ -211,7 +211,9 @@ public String getMsgAnnotated() {
try {
a.annotate(parent.build,this,markup);
} catch(Exception e) {
LOGGER.fine("ChangeLogAnnotator " + a.toString() + " failed to annotate message '" + getMsg() + "'; " + e.getMessage());
LOGGER.info("ChangeLogAnnotator " + a.toString() + " failed to annotate message '" + getMsg() + "'; " + e.getMessage());
} catch(Error e) {
LOGGER.severe("ChangeLogAnnotator " + a.toString() + " failed to annotate message '" + getMsg() + "'; " + e.getMessage());
}

return markup.toString(false);
Expand Down
47 changes: 47 additions & 0 deletions test/src/test/java/hudson/scm/ChangeLogSetTest.java
@@ -0,0 +1,47 @@
package hudson.scm;

import hudson.Extension;
import hudson.MarkupText;
import hudson.model.AbstractBuild;
import hudson.scm.ChangeLogSet.Entry;

import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.FakeChangeLogSCM.EntryImpl;
import org.jvnet.hudson.test.HudsonTestCase;

public class ChangeLogSetTest extends HudsonTestCase {

@Bug(17084)
public void testCatchingExceptionDuringAnnotation() throws Exception {
EntryImpl change = new EntryImpl();
change.setParent(ChangeLogSet.createEmpty(null)); // otherwise test would actually test only NPE thrown when accessing paret.build
boolean notCaught = false;
try {
change.getMsgAnnotated();
} catch (Throwable t) {
notCaught = true;
}
assertEquals((new EntryImpl()).getMsg(), change.getMsg());
assertEquals(false, notCaught);
}

@Extension
public static final class ThrowExceptionChangeLogAnnotator extends ChangeLogAnnotator {

@Override
public void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text ) {
throw new RuntimeException();
}

}

@Extension
public static final class ThrowErrorChangeLogAnnotator extends ChangeLogAnnotator {

@Override
public void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text ) {
throw new Error();
}

}
}

0 comments on commit 4a39c5a

Please sign in to comment.