|
14 | 14 | import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; |
15 | 15 | import software.amazon.awssdk.regions.Region; |
16 | 16 |
|
| 17 | +import org.apache.lucene.store.AlreadyClosedException; |
17 | 18 | import org.elasticsearch.cluster.ClusterState; |
18 | 19 | import org.elasticsearch.cluster.metadata.Metadata; |
19 | 20 | import org.elasticsearch.cluster.metadata.ProjectId; |
@@ -203,12 +204,15 @@ public void testClientsLifeCycleForSingleProject() throws Exception { |
203 | 204 | } |
204 | 205 | assertClientNotFound(projectId, clientName); |
205 | 206 |
|
206 | | - assertBusy(() -> assertTrue(clientsHolder.isClosed())); |
207 | | - final var e = expectThrows( |
208 | | - IllegalStateException.class, |
209 | | - () -> clientsHolder.client(createRepositoryMetadata(randomFrom(clientName, anotherClientName))) |
210 | | - ); |
211 | | - assertThat(e.getMessage(), containsString("Project [" + projectId + "] clients holder is closed")); |
| 207 | + assertBusy(() -> { |
| 208 | + assertTrue(clientsHolder.isClosed()); |
| 209 | + final var e = expectThrows(AlreadyClosedException.class, () -> { |
| 210 | + var client = clientsHolder.client(createRepositoryMetadata(randomFrom(clientName, anotherClientName))); |
| 211 | + client.decRef(); |
| 212 | + }); |
| 213 | + assertThat(e.getMessage(), containsString("Project [" + projectId + "] clients holder is closed")); |
| 214 | + }); |
| 215 | + |
212 | 216 | } |
213 | 217 |
|
214 | 218 | public void testClientsForMultipleProjects() throws InterruptedException { |
@@ -298,16 +302,16 @@ public void testClientsHolderAfterManagerClosed() { |
298 | 302 | final ProjectId projectId = randomUniqueProjectId(); |
299 | 303 | final String clientName = randomFrom(clientNames); |
300 | 304 |
|
301 | | - s3Service.close(); |
| 305 | + s3Service.close() |
302 | 306 | assertTrue(s3ClientsManager.isManagerClosed()); |
303 | 307 | // New holder can be added after the manager is closed, but no actual client can be created |
304 | 308 | updateProjectInClusterState(projectId, newProjectClientsSecrets(projectId, clientName)); |
305 | 309 | try (var clientsHolder = s3ClientsManager.getPerProjectClientsHolders().get(projectId)) { |
306 | 310 | assertNotNull(clientsHolder); |
307 | 311 | assertFalse(clientsHolder.isClosed()); |
308 | 312 |
|
309 | | - final IllegalStateException e = expectThrows( |
310 | | - IllegalStateException.class, |
| 313 | + final var e = expectThrows( |
| 314 | + AlreadyClosedException.class, |
311 | 315 | () -> s3ClientsManager.client(projectId, createRepositoryMetadata(clientName)) |
312 | 316 | ); |
313 | 317 | assertThat(e.getMessage(), containsString("s3 clients manager is closed")); |
|
0 commit comments