Skip to content

Commit 86b65f3

Browse files
ldemattegeorgewallace
authored andcommitted
Make NotEntitledException inherit from AccessControlException for compatibility purposes (elastic#124321)
Even if the contract for JDK methods using the SecurityManager states that the exception throw is of type SecurityException, many libraries (including our own, apparently!) violates that and use the type actually thrown by SecurityManager, AccessControlException. A prime example is the GCS/CSP libraries. In order to maintain compatibility for them, we need to inherit from the more specific AccessControlException; this is less desirable, as AccessControlException is marked as deprecated for removal alongside the other SecurityManager classes, but we discussed and found this is the best short term solution. More work will be needed -- again, this is a short term solution. Replaces elastic#123984
1 parent a4e32bf commit 86b65f3

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/NotEntitledException.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99

1010
package org.elasticsearch.entitlement.runtime.api;
1111

12-
public class NotEntitledException extends SecurityException {
12+
import java.security.AccessControlException;
13+
14+
public class NotEntitledException extends AccessControlException {
1315
public NotEntitledException(String message) {
1416
super(message);
1517
}
16-
17-
public NotEntitledException(String message, Throwable cause) {
18-
super(message, cause);
19-
}
2018
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationReloader.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
import org.elasticsearch.action.support.PlainActionFuture;
1313
import org.elasticsearch.common.ssl.SslConfiguration;
1414
import org.elasticsearch.core.TimeValue;
15-
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1615
import org.elasticsearch.watcher.FileChangesListener;
1716
import org.elasticsearch.watcher.FileWatcher;
1817
import org.elasticsearch.watcher.ResourceWatcherService;
1918
import org.elasticsearch.watcher.ResourceWatcherService.Frequency;
2019

2120
import java.io.IOException;
2221
import java.nio.file.Path;
23-
import java.security.AccessControlException;
2422
import java.util.ArrayList;
2523
import java.util.Collection;
2624
import java.util.HashMap;
@@ -110,7 +108,7 @@ private static void startWatching(
110108
fileWatcher.addListener(changeListener);
111109
try {
112110
resourceWatcherService.add(fileWatcher, Frequency.HIGH);
113-
} catch (IOException | AccessControlException | NotEntitledException e) {
111+
} catch (IOException | SecurityException e) {
114112
logger.error("failed to start watching directory [{}] for ssl configurations [{}] - {}", path, configurations, e);
115113
}
116114
});

0 commit comments

Comments
 (0)