arturobernalg commented on code in PR #614:
URL: https://github.com/apache/jspwiki/pull/614#discussion_r4579486153


##########
jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java:
##########
@@ -246,6 +246,10 @@ Collection< String > pageNamesFor( final String text ) 
throws Exception {
         final Context ctx = Wiki.context().create( m_engine, request, 
ContextEnum.PAGE_EDIT.getRequestContext() );
         final Collection< SearchResult > search = m_mgr.findPages( text, ctx );
         final List< String > names = new ArrayList<>();
+        if( search == null ) {
+            // the provider has no answer until its index is built, and the 
tests wait for a result with this method
+            return names;

Review Comment:
   The tests already wait, with an exit clause: they wait with Awaitility, 
whose default timeout is 10 seconds, before they assert, for example 
Awaitility.await("index").until(() -> pageNamesFor("name:blog").size() == 3). 
The failure was that pageNamesFor threw a NullPointerException when the 
provider had no answer yet, and Awaitility stops at the first exception thrown 
by the condition (checked with 4.3.0: an exception ends the wait at the first 
call, while a false answer is retried until the timeout). With the empty list 
the same wait goes on until the index answers or the 10 seconds pass, and then 
the test fails as before. The assertions that call pageNamesFor directly come 
after those waits, when the index is built, so a second wait inside the method 
would only repeat the first.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to