Skip to content

Commit 66aecf9

Browse files
authored
Merge branch 'main' into 2025/02/25/transport-handshake-patch
2 parents e0e015e + 84552f8 commit 66aecf9

File tree

24 files changed

+232
-63
lines changed

24 files changed

+232
-63
lines changed

.github/workflows/comment-on-asciidoc-changes.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/docs-build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: docs-build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request_target: ~
8+
merge_group: ~
9+
10+
jobs:
11+
docs-preview:
12+
uses: elastic/docs-builder/.github/workflows/preview-build.yml@main
13+
with:
14+
path-pattern: docs/**
15+
permissions:
16+
deployments: write
17+
id-token: write
18+
contents: read
19+
pull-requests: read

.github/workflows/docs-cleanup.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: docs-cleanup
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
jobs:
9+
docs-preview:
10+
uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main
11+
permissions:
12+
contents: none
13+
id-token: write
14+
deployments: write

docs/changelog/123569.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123569
2+
summary: Abort pending deletion on `IndicesService` close
3+
area: Store
4+
type: enhancement
5+
issues: []

libs/core/src/main/java/org/elasticsearch/core/Releasables.java

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.core;
1111

12-
import java.io.IOException;
13-
import java.io.UncheckedIOException;
1412
import java.util.Arrays;
1513
import java.util.Iterator;
1614
import java.util.concurrent.atomic.AtomicReference;
@@ -21,11 +19,17 @@ public enum Releasables {
2119

2220
/** Release the provided {@link Releasable}s. */
2321
public static void close(Iterable<? extends Releasable> releasables) {
24-
try {
25-
// this does the right thing with respect to add suppressed and not wrapping errors etc.
26-
IOUtils.close(releasables);
27-
} catch (IOException e) {
28-
throw new UncheckedIOException(e);
22+
RuntimeException firstException = null;
23+
for (final Releasable releasable : releasables) {
24+
try {
25+
close(releasable);
26+
} catch (RuntimeException e) {
27+
firstException = useOrSuppress(firstException, e);
28+
}
29+
}
30+
31+
if (firstException != null) {
32+
throw firstException;
2933
}
3034
}
3135

@@ -38,7 +42,18 @@ public static void close(@Nullable Releasable releasable) {
3842

3943
/** Release the provided {@link Releasable}s. */
4044
public static void close(Releasable... releasables) {
41-
close(true, releasables);
45+
RuntimeException firstException = null;
46+
for (final Releasable releasable : releasables) {
47+
try {
48+
close(releasable);
49+
} catch (RuntimeException e) {
50+
firstException = useOrSuppress(firstException, e);
51+
}
52+
}
53+
54+
if (firstException != null) {
55+
throw firstException;
56+
}
4257
}
4358

4459
/** Release the provided {@link Releasable}s expecting no exception to by thrown by any of them. */
@@ -63,19 +78,21 @@ public static void closeExpectNoException(Releasable releasable) {
6378

6479
/** Release the provided {@link Releasable}s, ignoring exceptions. */
6580
public static void closeWhileHandlingException(Releasable... releasables) {
66-
close(false, releasables);
81+
for (final Releasable releasable : releasables) {
82+
try {
83+
close(releasable);
84+
} catch (RuntimeException e) {
85+
// ignored
86+
}
87+
}
6788
}
6889

69-
/** Release the provided {@link Releasable}s, ignoring exceptions if <code>success</code> is {@code false}. */
70-
private static void close(boolean success, Releasable... releasables) {
71-
try {
72-
// this does the right thing with respect to add suppressed and not wrapping errors etc.
73-
IOUtils.close(releasables);
74-
} catch (IOException e) {
75-
if (success) {
76-
throw new UncheckedIOException(e);
77-
}
90+
private static RuntimeException useOrSuppress(RuntimeException firstException, RuntimeException e) {
91+
if (firstException == null || firstException == e) {
92+
return e;
7893
}
94+
firstException.addSuppressed(e);
95+
return firstException;
7996
}
8097

8198
/** Wrap several releasables into a single one. This is typically useful for use with try-with-resources: for example let's assume

libs/ssl-config/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ apply plugin: "elasticsearch.publish"
1010

1111
dependencies {
1212
api project(':libs:core')
13+
api project(':libs:entitlement')
1314

1415
testImplementation(project(":test:framework")) {
1516
exclude group: 'org.elasticsearch', module: 'ssl-config'

libs/ssl-config/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
module org.elasticsearch.sslconfig {
1111
requires org.elasticsearch.base;
12+
requires org.elasticsearch.entitlement;
1213

1314
exports org.elasticsearch.common.ssl;
1415
}

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemKeyConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.common.ssl;
1111

1212
import org.elasticsearch.core.Tuple;
13+
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1314

1415
import java.io.IOException;
1516
import java.nio.file.Path;
@@ -127,6 +128,8 @@ private PrivateKey getPrivateKey(Path path) {
127128
return privateKey;
128129
} catch (AccessControlException e) {
129130
throw SslFileUtil.accessControlFailure(KEY_FILE_TYPE, List.of(path), e, configBasePath);
131+
} catch (NotEntitledException e) {
132+
throw SslFileUtil.notEntitledFailure(KEY_FILE_TYPE, List.of(path), e, configBasePath);
130133
} catch (IOException e) {
131134
throw SslFileUtil.ioException(KEY_FILE_TYPE, List.of(path), e);
132135
} catch (GeneralSecurityException e) {

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemTrustConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.common.ssl;
1111

12+
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
13+
1214
import java.io.IOException;
1315
import java.io.InputStream;
1416
import java.nio.file.Path;
@@ -99,6 +101,8 @@ private List<Certificate> readCertificates(List<Path> paths) {
99101
return PemUtils.readCertificates(paths);
100102
} catch (AccessControlException e) {
101103
throw SslFileUtil.accessControlFailure(CA_FILE_TYPE, paths, e, basePath);
104+
} catch (NotEntitledException e) {
105+
throw SslFileUtil.notEntitledFailure(CA_FILE_TYPE, paths, e, basePath);
102106
} catch (IOException e) {
103107
throw SslFileUtil.ioException(CA_FILE_TYPE, paths, e);
104108
} catch (GeneralSecurityException e) {

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.common.ssl;
1111

1212
import org.elasticsearch.core.CharArrays;
13+
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1314

1415
import java.io.BufferedReader;
1516
import java.io.IOException;
@@ -112,6 +113,8 @@ public static PrivateKey readPrivateKey(Path path, Supplier<char[]> passwordSupp
112113
return privateKey;
113114
} catch (AccessControlException e) {
114115
throw SslFileUtil.accessControlFailure("PEM private key", List.of(path), e, null);
116+
} catch (NotEntitledException e) {
117+
throw SslFileUtil.notEntitledFailure("PEM private key", List.of(path), e, null);
115118
} catch (IOException e) {
116119
throw SslFileUtil.ioException("PEM private key", List.of(path), e);
117120
} catch (GeneralSecurityException e) {

0 commit comments

Comments
 (0)