Skip to content

Commit 0219c20

Browse files
author
Josh Peterson
committed
Don't use exceptions for time zones (case 1100856)
The current class library code uses managed exceptions for flow control for time zone handling. Specifically, it depends on exceptions to occur if one of the files that _might_ have time zone information does not exist. On Android with IL2CPP we run into problems with C++ exceptions causing hangs in some cases. Since IL2CPP implements managed exceptions using C++ exceptions, this code can cause problems. This change corrects Unity case 1100856.
1 parent a1597e0 commit 0219c20

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mcs/class/corlib/System/TimeZoneInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ static TimeZoneInfo CreateLocal ()
209209
string tzName = null;
210210
if (!TryGetNameFromPath (tzFilePath, out tzName))
211211
tzName = "Local";
212-
return FindSystemTimeZoneByFileName (tzName, tzFilePath);
212+
if (File.Exists(tzFilePath))
213+
return FindSystemTimeZoneByFileName (tzName, tzFilePath);
213214
} catch (TimeZoneNotFoundException) {
214215
continue;
215216
}
@@ -1561,4 +1562,4 @@ public override string ToString ()
15611562
}
15621563
#endif
15631564
}
1564-
}
1565+
}

0 commit comments

Comments
 (0)