Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit bf92dba

Browse files
Vizeraibogdandrutu
authored andcommitted
Removing AppEngine restriction on Java version. (#1944)
* Updating AppEngine Java version. * update
1 parent 0fa5564 commit bf92dba

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

impl_core/src/main/java/io/opencensus/implcore/internal/DaemonThreadFactory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222

2323
/** A {@link ThreadFactory} implementation that starts all {@link Thread} as daemons. */
2424
public 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
}

0 commit comments

Comments
 (0)