Skip to content

Commit

Permalink
Finally fix grepper never finishing...
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyD97 committed May 24, 2023
1 parent 05a14f3 commit 8adc11a
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,30 @@ private void processMatches(GrepResults grepResults, Pattern pattern, byte[] con
private Runnable createProcessThread(final LogEntry logEntry, final Pattern pattern,
final boolean inScopeOnly, final boolean searchRequests, final boolean searchResponses) {
return () -> {
if (Thread.currentThread().isInterrupted()) return;
GrepResults grepResults = null;
if (!inScopeOnly || LoggerPlusPlus.isUrlInScope(logEntry.getUrlString())) {
grepResults = processEntry(logEntry, pattern, searchRequests, searchResponses);
}
for (GrepperListener listener : this.listeners) {
try {
listener.onEntryProcessed(grepResults);
} catch (Exception e) {
e.printStackTrace();
try {
if (Thread.currentThread().isInterrupted()) return;
GrepResults grepResults = null;
if (!inScopeOnly || LoggerPlusPlus.isUrlInScope(logEntry.getUrlString())) {
grepResults = processEntry(logEntry, pattern, searchRequests, searchResponses);
}
}
int remaining = remainingEntries.decrementAndGet();
if(remaining == 0){
for (GrepperListener listener : listeners) {
for (GrepperListener listener : this.listeners) {
try {
listener.onSearchComplete();
}catch (Exception e){
listener.onEntryProcessed(grepResults);
} catch (Exception e) {
e.printStackTrace();
}
}
}finally {
int remaining = remainingEntries.decrementAndGet();
if (remaining == 0) {
for (GrepperListener listener : listeners) {
try {
listener.onSearchComplete();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
};
}
Expand Down

0 comments on commit 8adc11a

Please # to comment.