This repository was archived by the owner on Dec 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
impl_core/src/main/java/io/opencensus/implcore/internal Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 2222
2323/** A {@link ThreadFactory} implementation that starts all {@link Thread} as daemons. */
2424public final class DaemonThreadFactory implements ThreadFactory {
25- // AppEngine runtimes have constraints on threading and socket handling
26- // that need to be accommodated.
27- public static final boolean IS_RESTRICTED_APPENGINE =
28- System .getProperty ("com.google.appengine.runtime.environment" ) != null
29- && "1.7" .equals (System .getProperty ("java.specification.version" ));
3025 private static final String DELIMITER = "-" ;
3126 private static final ThreadFactory threadFactory = MoreExecutors .platformThreadFactory ();
3227 private final AtomicInteger threadIdGen = new AtomicInteger ();
@@ -44,9 +39,12 @@ public DaemonThreadFactory(String threadPrefix) {
4439 @ Override
4540 public Thread newThread (Runnable r ) {
4641 Thread thread = threadFactory .newThread (r );
47- if (!IS_RESTRICTED_APPENGINE ) {
42+ // AppEngine runtimes have constraints on thread renaming.
43+ try {
4844 thread .setName (threadPrefix + threadIdGen .getAndIncrement ());
4945 thread .setDaemon (true );
46+ } catch (SecurityException e ) {
47+ // OK if we can't set the name or daemon in this environment.
5048 }
5149 return thread ;
5250 }
You can’t perform that action at this time.
0 commit comments