EC2 Waiter `waitUntilInstanceRunning` Hanging When `DescribeInstancesRequest` Empty
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
### Describe the bug
The following code hangs indefinitely when there are no `pending` EC2 instances and only `running` EC2 instances. Adding both `pending` and `running` to the filter works properly, but intuitively, it seems like when `DescribeInstancesRequest` returns no instances, the waiter should return or fail, not wait indefinitely.
```
ec2Client.waiter().waitUntilInstanceRunning(DescribeInstancesRequest.builder()
.filters(Filter.builder()
.name("instance-state-name")
.values("pending")
.build())
.build());
```
### Expected Behavior
The `waitUntilInstanceRunning` call to return immediately when the `DescribeInstancesRequest` yields no instances.
### Current Behavior
The `waitUntilInstanceRunning` call with the aforementioned `DescribeInstancesRequest` and `running` EC2 instance states hangs and waits indefinitely.
### Reproduction Steps
See description.
### Possible Solution
When the `DescribeInstancesRequest` given to the `waitUntilInstanceRunning` yields an empty result (no instances), the waiter should succeed and return immediately. This may have unintended consequences so perhaps it should just fail or the `WaiterOverrideConfiguration` could have an option to allow empty results from the `DescribeInstancesRequest`.
### Additional Information/Context
_No response_
### AWS Java SDK version used
2.25.15
### JDK version used
21
### Operating System and version
Linux Ubuntu 22.04
Contributor guide
Assessment
This issue has not been assessed yet.