@@ -35,6 +35,9 @@ public class RunnableScanner extends ARunnable {
3535 private Map <String , Pattern > sigMap = null ;
3636 private Map <String , String > allowedSigMap = null ;
3737 private Map <String , List <String >> excludeExtMap = null ;
38+ private FxCallback fxCallback = (type , message ) -> {
39+ log .info (message );
40+ };
3841
3942 public RunnableScanner () {
4043 }
@@ -59,6 +62,10 @@ public void setFoundItemsContainer(FoundItemsContainer foundItemsContainer) {
5962 this .foundItemsContainer = foundItemsContainer ;
6063 }
6164
65+ public void setFxCallback (FxCallback fxCallback ) {
66+ this .fxCallback = fxCallback ;
67+ }
68+
6269 @ Override
6370 protected Logger getLog () {
6471 return log ;
@@ -71,25 +78,28 @@ protected void _run() throws IOException {
7178 Path gitConfigPath = Paths .get (dirToScan , ".git" , "config" );
7279 File gitConfigFile = gitConfigPath .toFile ();
7380 if (!gitConfigFile .exists () || !gitConfigFile .isFile ()) {
74- AlertBuilder . showWarn ( """
81+ fxCallback . showMessage ( FxCallback . FxCallbackType . WARNING , """
7582 You've selected not a root of a git-repository.
7683 You can continue using scanner but exclusion file may be created/written not in the canonical place.
7784 Existed exclusion configurations will not be shown""" );
7885 }
7986
8087 if (sigMap == null || sigMap .isEmpty ()) {
81- AlertBuilder . showError ( "Load signatures first. Nothing to scan by." );
88+ fxCallback . showMessage ( FxCallback . FxCallbackType . ERROR , "Load signatures first. Nothing to scan by." );
8289 return ;
8390 }
8491
8592 // try loading exclusions-model from the file in the root of the repository
8693 ExcludeFileModel tmpExcludeFileModel = new ExcludeFileModel (); // create empty container
87- Path exFile = Paths .get (dirToScan , Excluder .PERSISTENCE_FOLDER , Excluder .EXCLUDES_SHORT_FILE_NAME );
94+ Path exFilePath = Paths .get (dirToScan , Excluder .PERSISTENCE_FOLDER , Excluder .EXCLUDES_SHORT_FILE_NAME );
8895 try {
89- OBJECT_MAPPER .enable (JsonParser .Feature .INCLUDE_SOURCE_IN_LOCATION );
90- tmpExcludeFileModel = OBJECT_MAPPER .readValue (exFile .toFile (), ExcludeFileModel .class ); // load new exclusion context
96+ File exFile = exFilePath .toFile ();
97+ if (exFile .exists () && exFile .isFile ()) {
98+ OBJECT_MAPPER .enable (JsonParser .Feature .INCLUDE_SOURCE_IN_LOCATION );
99+ tmpExcludeFileModel = OBJECT_MAPPER .readValue (exFile , ExcludeFileModel .class ); // load new exclusion context
100+ }
91101 } catch (Exception ex ) {
92- log .error ("Error while loading exclusions configuration from '{}' file" , exFile , ex );
102+ log .error ("Error while loading exclusions configuration from '{}' file" , exFilePath , ex );
93103 }
94104
95105 final ExcludeFileModel excludeFileModel = tmpExcludeFileModel ;
@@ -150,7 +160,8 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
150160 List <FoundPathItem > list = foundItemsContainer .getFoundItemsCopy ();
151161 final AtomicInteger numberOfThreadsInProgress = new AtomicInteger (0 );
152162
153- try (var executor = Executors .newVirtualThreadPerTaskExecutor ()) {
163+ // try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
164+ try (var executor = Executors .newSingleThreadExecutor ()) {
154165 list .forEach (pathItem -> {
155166 executor .submit (() -> {
156167 numberOfThreadsInProgress .incrementAndGet ();
@@ -215,6 +226,9 @@ private void scan(FoundPathItem pathItem, Path rootDir, ExcludeFileModel exclude
215226 Path filePath = pathItem .getFilePath ();
216227 String fileBody ;
217228 try {
229+ System .out .println ("Reading file " + filePath );
230+
231+ log .info ("Reading file {}" , filePath );
218232 fileBody = FileUtils .readFile (filePath );
219233 } catch (IOException ex ) {
220234 log .error ("Error while reading file '{}'. Skipping it." , filePath , ex );
0 commit comments