Projects STRLCPY LoggerPlusPlus Commits 8adc11a7
🤬
  • Finally fix grepper never finishing...

  • Loading...
  • Corey committed 10 months ago
    8adc11a7
    1 parent 05a14f3a
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/grepper/GrepperController.java
    skipped 120 lines
    121 121   private Runnable createProcessThread(final LogEntry logEntry, final Pattern pattern,
    122 122   final boolean inScopeOnly, final boolean searchRequests, final boolean searchResponses) {
    123 123   return () -> {
    124  - if (Thread.currentThread().isInterrupted()) return;
    125  - GrepResults grepResults = null;
    126  - if (!inScopeOnly || LoggerPlusPlus.isUrlInScope(logEntry.getUrlString())) {
    127  - grepResults = processEntry(logEntry, pattern, searchRequests, searchResponses);
    128  - }
    129  - for (GrepperListener listener : this.listeners) {
    130  - try {
    131  - listener.onEntryProcessed(grepResults);
    132  - } catch (Exception e) {
    133  - e.printStackTrace();
     124 + try {
     125 + if (Thread.currentThread().isInterrupted()) return;
     126 + GrepResults grepResults = null;
     127 + if (!inScopeOnly || LoggerPlusPlus.isUrlInScope(logEntry.getUrlString())) {
     128 + grepResults = processEntry(logEntry, pattern, searchRequests, searchResponses);
    134 129   }
    135  - }
    136  - int remaining = remainingEntries.decrementAndGet();
    137  - if(remaining == 0){
    138  - for (GrepperListener listener : listeners) {
     130 + for (GrepperListener listener : this.listeners) {
    139 131   try {
    140  - listener.onSearchComplete();
    141  - }catch (Exception e){
     132 + listener.onEntryProcessed(grepResults);
     133 + } catch (Exception e) {
    142 134   e.printStackTrace();
     135 + }
     136 + }
     137 + }finally {
     138 + int remaining = remainingEntries.decrementAndGet();
     139 + if (remaining == 0) {
     140 + for (GrepperListener listener : listeners) {
     141 + try {
     142 + listener.onSearchComplete();
     143 + } catch (Exception e) {
     144 + e.printStackTrace();
     145 + }
    143 146   }
    144 147   }
    145 148   }
    skipped 44 lines
Please wait...
Page is in error, reload to recover