Рефакторинг
This commit is contained in:
@@ -77,18 +77,16 @@ public class PcapWorker implements PacketListener {
|
|||||||
BasicThreadFactory factory = new BasicThreadFactory.Builder()
|
BasicThreadFactory factory = new BasicThreadFactory.Builder()
|
||||||
.namingPattern("pcap-worker-loop").build();
|
.namingPattern("pcap-worker-loop").build();
|
||||||
ExecutorService loopExecutorService = Executors.newSingleThreadExecutor(factory);
|
ExecutorService loopExecutorService = Executors.newSingleThreadExecutor(factory);
|
||||||
loopExecutorService.execute(() -> {
|
try {
|
||||||
try {
|
log.info("Intercept started");
|
||||||
log.info("Intercept started");
|
pcap.loop(-1, this, loopExecutorService);
|
||||||
pcap.loop(-1, this); // использовать другой executor?
|
} catch (InterruptedException ignored) {
|
||||||
} catch (InterruptedException ignored) {
|
Thread.currentThread().interrupt();
|
||||||
Thread.currentThread().interrupt();
|
// выходим
|
||||||
// выходим
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
log.error("Error while capturing packet", e);
|
||||||
log.error("Error while capturing packet", e);
|
stop();
|
||||||
stop();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
|
|||||||
Reference in New Issue
Block a user