Skip to content

Commit

Permalink
Avoid IDE warning
Browse files Browse the repository at this point in the history
The IDE can't figure out that service is never null if the loop exits
without an exception.
  • Loading branch information
markt-asf committed Nov 27, 2024
1 parent b742e65 commit 5fe0c23
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions test/org/apache/catalina/startup/TestTomcatStandalone.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,15 @@ public void run() {

Service service = null;
int i = 0;
while (true) {
Assert.assertTrue(i++ < 500);
if (service == null) {
Server server = catalina.getServer();
if (server != null && catalina.getServer().findServices().length > 0) {
service = catalina.getServer().findServices()[0];
}
}
if (service != null && service.getState() == LifecycleState.STARTED) {
break;
while (i < 500 && (service == null || service.getState() != LifecycleState.STARTED)) {
Server server = catalina.getServer();
if (server != null && catalina.getServer().findServices().length > 0) {
service = catalina.getServer().findServices()[0];
}
Thread.sleep(10);
i++;
}
Assert.assertNotNull(service);

Connector connector = service.findConnectors()[0];
res = TomcatBaseTest.getUrl("http://localhost:" + connector.getLocalPort() + "/");
Expand Down

0 comments on commit 5fe0c23

Please sign in to comment.