提交 0c467012 编写于 作者: V Vojtech Juranek

[FIXED JENKINS-17084] Changelog should produce output even if some changelog annotator fails

上级 d6bec48f
......@@ -211,7 +211,9 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
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);
......
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();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册