@@ -199,23 +199,24 @@ private static TestSuite _suite(Predicate<Map<String,Object>> accept, boolean sk
199199 try (CloseableHttpClient client = WebTestHelper .getHttpClient ())
200200 {
201201 final String url = WebTestHelper .getBaseURL () + "/junit-testlist.view" ;
202- HttpGet whoAmI = new HttpGet (WebTestHelper .buildURL ("login " , "whoami .api" ));
203- HttpGet method = new HttpGet (url );
202+ HttpGet ensureLogin = new HttpGet (WebTestHelper .buildURL ("security " , "ensureLogin .api" ));
203+ HttpGet getTestList = new HttpGet (url );
204204 try
205205 {
206- client .execute (whoAmI , context , r -> {
206+ client .execute (ensureLogin , context , r -> {
207+ String ensureLoginResponse = WebTestHelper .getHttpResponseBody (r );
207208 try
208209 {
209- JSONObject jsonObject = new JSONObject (WebTestHelper . getHttpResponseBody ( r ) );
210- LOG .info ("WhoAmI : {}" , jsonObject .getString ("email" ));
210+ JSONObject jsonObject = new JSONObject (ensureLoginResponse );
211+ LOG .info ("ensureLogin : {}" , jsonObject . getJSONObject ( "currentUser" ) .getString ("email" ));
211212 }
212213 catch (JSONException e )
213214 {
214- LOG .info ("WhoAmI : {}" , r . getCode () );
215+ LOG .info ("ensureLogin : {}" , ensureLoginResponse );
215216 }
216217 return null ;
217218 });
218- response = client .execute (method , context );
219+ response = client .execute (getTestList , context );
219220 }
220221 catch (IOException ex )
221222 {
@@ -253,6 +254,7 @@ private static TestSuite _suite(Predicate<Map<String,Object>> accept, boolean sk
253254 // Server still starting up. We don't need to use the upgradeHelper to sign in.
254255 LOG .info ("Remote JUnitTest: Server modules starting up (remaining " + TestDateUtils .durationString (startupTimer .timeRemaining ()) + ") ..." );
255256
257+ EntityUtils .consumeQuietly (response .getEntity ()); // Consume before possible recursion
256258 if (!startupTimer .isTimedOut ())
257259 {
258260 Thread .sleep (1000 );
@@ -271,6 +273,7 @@ else if (responseBody.contains("<title>Upgrade Status</title>") ||
271273 responseBody .contains ("<title>Account Setup</title>" ) ||
272274 responseBody .contains ("This server is being upgraded to a new version of LabKey Server." ))
273275 {
276+ EntityUtils .consumeQuietly (response .getEntity ()); // Consume before possible recursion
274277 LOG .info ("Remote JUnitTest: Server needs install or upgrade ..." );
275278 if (upgradeAttempts > 3 )
276279 throw new AssertionFailedError ("Failed to update or bootstrap on second attempt: " + responseBody );
0 commit comments