@@ -377,7 +377,13 @@ private CompletableFuture<Void> _initializeProject(IJavaProject project, boolean
377377
378378 CompletableFuture <Void > future = CompletableFuture .allOf (futures );
379379
380- future = future .thenAccept (v -> server .getClient ().indexUpdated (IndexUpdatedParams .of (Set .of (project .getElementName ())))).thenAccept (v -> listeners .fire (v ));
380+ future = future
381+ .thenAccept (v -> {
382+ if (server .getClient () != null ) {
383+ server .getClient ().indexUpdated (IndexUpdatedParams .of (Set .of (project .getElementName ())));
384+ }
385+ })
386+ .thenAccept (v -> listeners .fire (v ));
381387
382388 this .latestScheduledTaskByProject .put (project .getElementName (), future );
383389 return future ;
@@ -449,7 +455,13 @@ public CompletableFuture<Void> createDocuments(String[] docURIs) {
449455 }
450456
451457 CompletableFuture <Void > future = CompletableFuture .allOf ((CompletableFuture []) futures .toArray (new CompletableFuture [futures .size ()]));
452- future = future .thenAccept (v -> server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ))).thenAccept (v -> listeners .fire (v ));
458+ future = future
459+ .thenAccept (v -> {
460+ if (server .getClient () != null ) {
461+ server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ));
462+ }
463+ })
464+ .thenAccept (v -> listeners .fire (v ));
453465 return future ;
454466 }
455467 }
@@ -507,7 +519,13 @@ public CompletableFuture<Void> updateDocument(String docURI, String content, Str
507519 }
508520 }
509521 CompletableFuture <Void > future = CompletableFuture .allOf ((CompletableFuture []) futures .toArray (new CompletableFuture [futures .size ()]));
510- future = future .thenAccept (v -> server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ))).thenAccept (v -> listeners .fire (v ));
522+ future = future
523+ .thenAccept (v -> {
524+ if (server .getClient () != null ) {
525+ server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ));
526+ }
527+ })
528+ .thenAccept (v -> listeners .fire (v ));
511529 return future ;
512530 }
513531 }
@@ -541,7 +559,13 @@ public CompletableFuture<Void> updateDocuments(String[] docURIs, String reason)
541559 }
542560 }
543561 CompletableFuture <Void > future = CompletableFuture .allOf ((CompletableFuture []) futures .toArray (new CompletableFuture [futures .size ()]));
544- future = future .thenAccept (v -> server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ))).thenAccept (v -> listeners .fire (v ));
562+ future = future
563+ .thenAccept (v -> {
564+ if (server .getClient () != null ) {
565+ server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ));
566+ }
567+ })
568+ .thenAccept (v -> listeners .fire (v ));
545569 return future ;
546570 }
547571 }
@@ -629,7 +653,13 @@ public CompletableFuture<Void> deleteDocuments(String[] deletedPathURIs) {
629653
630654 if (futures .size () > 0 ) {
631655 CompletableFuture <Void > future = CompletableFuture .allOf ((CompletableFuture []) futures .toArray (new CompletableFuture [futures .size ()]));
632- future = future .thenAccept (v -> server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ))).thenAccept (v -> listeners .fire (v ));
656+ future = future
657+ .thenAccept (v -> {
658+ if (server .getClient () != null ) {
659+ server .getClient ().indexUpdated (IndexUpdatedParams .of (affectedProjects ));
660+ }
661+ })
662+ .thenAccept (v -> listeners .fire (v ));
633663 return future ;
634664 }
635665 else {
@@ -941,7 +971,10 @@ public void run() {
941971 index .removeProject (project );
942972 }
943973 springIndex .removeProject (project .getElementName ());
944- server .getClient ().indexUpdated (IndexUpdatedParams .of (project .getElementName ()));
974+
975+ if (server .getClient () != null ) {
976+ server .getClient ().indexUpdated (IndexUpdatedParams .of (project .getElementName ()));
977+ }
945978
946979 log .debug ("{} completed" , this );
947980 } catch (Throwable e ) {
0 commit comments