Skip to content

Commit fe99ad0

Browse files
Merge pull request #55 from nlnwa/fix-fetch-timeout-worker-loop
Fix potential infinite loop or exception
2 parents 30963d7 + 6c97482 commit fe99ad0

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/java/no/nb/nna/veidemann/frontier/db/CrawlQueueWorker.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,11 @@ public void run() {
111111
Error err = ExtraStatusCodes.RUNTIME_EXCEPTION.toFetchError("Timeout waiting for Harvester");
112112

113113
try (JedisContext ctx = JedisContext.forPool(jedisPool)) {
114-
String chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY);
115-
while (chgId != null) {
114+
for (String chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY); chgId != null; chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY)) {
116115
try {
117116
CrawlHostGroup chg = frontier.getCrawlQueueManager().getCrawlHostGroup(chgId);
118117
if (chg.getCurrentUriId().isEmpty()) {
119-
frontier.getCrawlQueueManager().releaseCrawlHostGroup(ctx, chg.getId(), chg.getSessionToken(), 0, true);
118+
frontier.getCrawlQueueManager().releaseCrawlHostGroup(ctx, chgId, chg.getSessionToken(), 0, true);
120119
continue;
121120
}
122121
PostFetchHandler postFetchHandler = new PostFetchHandler(chg, frontier, false);
@@ -125,8 +124,6 @@ public void run() {
125124
} catch (Exception e) {
126125
LOG.warn("Error while getting chg {}", chgId, e);
127126
}
128-
129-
chgId = ctx.getJedis().lpop(CHG_TIMEOUT_KEY);
130127
}
131128
} catch (Exception e) {
132129
e.printStackTrace();

0 commit comments

Comments
 (0)