File tree 1 file changed +18
-6
lines changed
client/sniffer/src/main/java/org/elasticsearch/client/sniff
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 27
27
28
28
import java .io .Closeable ;
29
29
import java .io .IOException ;
30
+ import java .security .AccessController ;
31
+ import java .security .PrivilegedAction ;
30
32
import java .util .List ;
31
33
import java .util .concurrent .Executors ;
32
34
import java .util .concurrent .ScheduledExecutorService ;
@@ -164,15 +166,25 @@ private static class SnifferThreadFactory implements ThreadFactory {
164
166
165
167
private SnifferThreadFactory (String namePrefix ) {
166
168
this .namePrefix = namePrefix ;
167
- this .originalThreadFactory = Executors .defaultThreadFactory ();
169
+ this .originalThreadFactory = AccessController .doPrivileged (new PrivilegedAction <ThreadFactory >() {
170
+ @ Override
171
+ public ThreadFactory run () {
172
+ return Executors .defaultThreadFactory ();
173
+ }
174
+ });
168
175
}
169
176
170
177
@ Override
171
- public Thread newThread (Runnable r ) {
172
- Thread t = this .originalThreadFactory .newThread (r );
173
- t .setName (namePrefix + "[T#" + threadNumber .getAndIncrement () + "]" );
174
- t .setDaemon (true );
175
- return t ;
178
+ public Thread newThread (final Runnable r ) {
179
+ return AccessController .doPrivileged (new PrivilegedAction <Thread >() {
180
+ @ Override
181
+ public Thread run () {
182
+ Thread t = originalThreadFactory .newThread (r );
183
+ t .setName (namePrefix + "[T#" + threadNumber .getAndIncrement () + "]" );
184
+ t .setDaemon (true );
185
+ return t ;
186
+ }
187
+ });
176
188
}
177
189
}
178
190
}
You can’t perform that action at this time.
0 commit comments