Greengrass DiscoveryClient does not work if a SecurityManager is installed #320
Labels
bug
This issue is a bug.
p2
This is a standard priority issue
pending-release
This issue will be fixed by an approved PR that hasn't been released yet.
Describe the bug
If a SecurityManager is installed, Greengrass Core Device discovery performed using DiscoveryClient will fail even with a permissive policy.
Expected Behavior
Greengrass Discovery completes successfully even if a security manager is installed.
Current Behavior
Greengrass Core Device discovery performed using DiscoveryClient fails with exception [1]
[1]
Reproduction Steps
Build a standalone JAR file that executes https://github.com/aws/aws-iot-device-sdk-java-v2/blob/main/samples/Greengrass/src/main/java/greengrass/BasicDiscovery.java as main class. This can obtained for example by adding the snippet [1] to the build -> plugins section of https://github.com/aws/aws-iot-device-sdk-java-v2/blob/main/samples/Greengrass/pom.xml.
Run the produced jar file with the following command:
java -Djava.security.manager -Djava.security.policy=security.policy -jar ./Greengrass-1.0-SNAPSHOT-jar-with-dependencies.jar ${DISCOVERY_SAMPLE_ARGS}
where
DISCOVERY_SAMPLE_ARGS
is as described in https://docs.aws.amazon.com/greengrass/v2/developerguide/test-client-device-communications.html#test-client-device-communications-java andsecurity.policy
contains the following maximally permissive policy:The command should fail logging the reported exception if the
-Djava.security.manager -Djava.security.policy=security.policy
arguments are provided and succeed if they are removed.[1]
Possible Solution
The issue is likely caused by the fact that
aws-iot-device-sdk-java-v2/sdk/src/main/java/software/amazon/awssdk/iot/discovery/DiscoveryClient.java
Line 97 in 472d0ec
is executed through CompletableFuture.supplyAsync() using the Fork Join Pool common pool.
Quoting from ForkJoinPool Javadoc, If a SecurityManager is present and no factory is specified, then the default pool uses a factory supplying threads that have no Permissions enabled..
Additional Information/Context
No response
SDK version used
main branch cloned from 1a2e1b5
Environment details (OS name and version, etc.)
Raspberry PI OS, openjdk version "1.8.0_312" OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-1+rpi1-b07) OpenJDK Client VM (build 25.312-b07, mixed mode)
The text was updated successfully, but these errors were encountered: