Skip to content

Commit

Permalink
#645 check for invalid comment numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Nov 9, 2014
1 parent dd30453 commit 81bff65
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/com/rultor/agents/github/Understands.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
@Immutable
@ToString
@EqualsAndHashCode(callSuper = false, of = { "github", "question" })
@SuppressWarnings("PMD.CyclomaticComplexity")
public final class Understands extends AbstractAgent {

/**
Expand Down Expand Up @@ -124,6 +125,14 @@ public Iterable<Directive> 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(
Expand All @@ -141,7 +150,7 @@ public Iterable<Directive> 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());
}
Expand Down

0 comments on commit 81bff65

Please sign in to comment.