Changeset 13273 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2018-01-03T03:41:29+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #15722 - make sure that JOSM ForkJoinPool instances create threads with same permissions than JOSM

This is not the case with default JDK thread factory when JOSM is run with Java Web Start, as the presence of a security manager leads to threads created without any permission

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r13173 r13273  
    11971197
    11981198    /**
     1199     * A ForkJoinWorkerThread that will always inherit caller permissions,
     1200     * unlike JDK's InnocuousForkJoinWorkerThread, used if a security manager exists.
     1201     */
     1202    static final class JosmForkJoinWorkerThread extends ForkJoinWorkerThread {
     1203        JosmForkJoinWorkerThread(ForkJoinPool pool) {
     1204            super(pool);
     1205        }
     1206    }
     1207
     1208    /**
    11991209     * Returns a {@link ForkJoinPool} with the parallelism given by the preference key.
    12001210     * @param pref The preference key to determine parallelism
     
    12091219            @Override
    12101220            public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
    1211                 final ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
     1221                // Do not use JDK default thread factory !
     1222                // If JOSM is started with Java Web Start, a security manager is installed and the factory
     1223                // creates threads without any permission, forbidding them to load a class instantiating
     1224                // another ForkJoinPool such as MultipolygonBuilder (see bug #15722)
     1225                final ForkJoinWorkerThread thread = new JosmForkJoinWorkerThread(pool);
    12121226                thread.setName(String.format(Locale.ENGLISH, nameFormat, count.getAndIncrement()));
    12131227                thread.setPriority(threadPriority);
Note: See TracChangeset for help on using the changeset viewer.