File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
modules/repository-s3/src
main/java/org/elasticsearch/repositories/s3
test/java/org/elasticsearch/repositories/s3 Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ final AmazonS3Reference client(RepositoryMetadata repositoryMetadata) {
290290 }
291291 if (closed .get ()) {
292292 // Not adding a new client once the manager is closed since there won't be anything to close it
293- throw new IllegalStateException ("clients holder is closed" );
293+ throw new IllegalStateException ("Project [" + projectId () + "] clients holder is closed" );
294294 }
295295 // The close() method maybe called after we checked it, it is ok since we are already inside the synchronized block.
296296 // The clearCache() will clear the newly added client.
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ public void testDoesNotCreateClientWhenSecretsAreNotConfigured() {
152152 assertThat (getClientsHoldersExcludeDefaultProject (), anEmptyMap ());
153153 }
154154
155- public void testClientsLifeCycleForSingleProject () {
155+ public void testClientsLifeCycleForSingleProject () throws Exception {
156156 final ProjectId projectId = randomUniqueProjectId ();
157157 final String clientName = randomFrom (clientNames );
158158 final String anotherClientName = randomValueOtherThan (clientName , () -> randomFrom (clientNames ));
@@ -197,13 +197,22 @@ public void testClientsLifeCycleForSingleProject() {
197197 antherClient .decRef ();
198198 }
199199
200+ final var clientsHolder = s3ClientsManager .getClientsHolders ().get (projectId );
201+
200202 // Remove project secrets
201203 if (randomBoolean ()) {
202204 updateProjectInClusterState (projectId , Map .of ());
203205 } else {
204206 removeProjectFromClusterState (projectId );
205207 }
206208 assertClientNotFound (projectId , clientName );
209+
210+ assertBusy (() -> assertTrue (clientsHolder .isClosed ()));
211+ final var e = expectThrows (
212+ IllegalStateException .class ,
213+ () -> clientsHolder .client (createRepositoryMetadata (randomFrom (clientName , anotherClientName )))
214+ );
215+ assertThat (e .getMessage (), containsString ("Project [" + projectId + "] clients holder is closed" ));
207216 }
208217
209218 public void testClientsForMultipleProjects () throws InterruptedException {
You can’t perform that action at this time.
0 commit comments