From 81bff65f2fdec735c8cd2ff7a48ad6b02c7939af Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 9 Nov 2014 16:30:15 +0100 Subject: [PATCH] #645 check for invalid comment numbers --- .../java/com/rultor/agents/github/Understands.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rultor/agents/github/Understands.java b/src/main/java/com/rultor/agents/github/Understands.java index 78bf346b98..5d331f06a5 100644 --- a/src/main/java/com/rultor/agents/github/Understands.java +++ b/src/main/java/com/rultor/agents/github/Understands.java @@ -62,6 +62,7 @@ @Immutable @ToString @EqualsAndHashCode(callSuper = false, of = { "github", "question" }) +@SuppressWarnings("PMD.CyclomaticComplexity") public final class Understands extends AbstractAgent { /** @@ -124,6 +125,14 @@ public Iterable process(final XML xml) throws IOException { break; } } + if (next < seen) { + throw new IllegalStateException( + String.format( + "comment #%d is younger than #%d, something is wrong", + next, seen + ) + ); + } final Directives dirs = new Directives(); if (req.equals(Req.EMPTY)) { Logger.info( @@ -141,7 +150,7 @@ public Iterable process(final XML xml) throws IOException { issue.repo().coordinates(), issue.number(), next ); } else { - dirs.xpath("/talk[not(request)]").add("request") + dirs.xpath("/talk[not(request)]").strict(1).add("request") .attr("id", Integer.toString(next)) .append(req.dirs()); }