srowen commented on a change in pull request #23812: [SPARK-26903][SQL] Remove 
the TimeZone cache
URL: https://github.com/apache/spark/pull/23812#discussion_r257516992
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
 ##########
 @@ -67,13 +66,9 @@ object DateTimeUtils {
 
   def defaultTimeZone(): TimeZone = TimeZone.getDefault()
 
-  private val computedTimeZones = new ConcurrentHashMap[String, TimeZone]
-  private val computeTimeZone = new JFunction[String, TimeZone] {
-    override def apply(timeZoneId: String): TimeZone = 
TimeZone.getTimeZone(timeZoneId)
-  }
-
   def getTimeZone(timeZoneId: String): TimeZone = {
-    computedTimeZones.computeIfAbsent(timeZoneId, computeTimeZone)
+    val zoneId = ZoneId.of(timeZoneId, ZoneId.SHORT_IDS)
+    TimeZone.getTimeZone(zoneId)
 
 Review comment:
   Oh I see, `TimeZone.getTimeZone(String)` is synchronized but this is now 
calling`TimeZone.getTimeZone(ZoneId)` which isn't.
   
   Yes this seems OK. The new code path entails a little more parsing and 
overhead vs just looking up the cached value, but this isn't a 'hot' path to 
begin with. I think it's worth removing this extra level of caching for 
simplicity, yes.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to