Can parallelStream be used in Webstart applications?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Can parallelStream be used in Webstart applications?

Stefan Fuchs
Hi,

a recent change in our webstart application triggered various
PermissionExceptions all over the place.
 From injection failures in guice (tried to use reflection to update a
private member) to loading resources with getResource().
This was odd given that our application is started with all-permissions.
Moreover the application worked fine (using various functions, which
require elevated permissions) until a certain function was triggered.


Bisecting revealed that the problem was triggered by a call to
|CompletableFuture
<https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html>::||supplyAsync
<https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html#supplyAsync-java.util.function.Supplier->(Supplier
<https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html><U>
supplier).

Reading the fine-print in the class description of |ForkJoinPool, we
found out that the threads created with no Permissions enabled.

"If a |SecurityManager|
<https://docs.oracle.com/javase/8/docs/api/java/lang/SecurityManager.html>
is present and no factory is specified, then the default pool uses a
factory supplying threads that have no |Permissions|
<https://docs.oracle.com/javase/8/docs/api/java/security/Permissions.html>
enabled. The system class loader is used to load these classes."

So we think what, happens is that certain application classes are loaded
in the context of the restricted thread and are therefor unable to
function properly.

While we could fix the above problem by passing our own ExecutorService
to the appropriate variant of the above method, we wonder what happens,
if the common ForkJoinPool is used by some code, that is not under our
control, say some linked framework or even the jdk itself.

Perhaps we could add the code mentioned here at are very early stage of
our application?
http://stackoverflow.com/questions/34303094/is-it-not-possible-to-supply-a-thread-facory-or-name-pattern-to-forkjoinpool


The issue has been raised before in
https://bugs.openjdk.java.net/browse/JDK-8143638 . The bug was however
closed as not an issue.

So is every Webstart application using parallelStream and co. to
implement the above workaround?


Any thoughts?


Stefan Fuchs
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest