Skip to content

Commit 68ec759

Browse files
committed
Unwrap the original exception
1 parent 61038ea commit 68ec759

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeFormatterHelper.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import java.util.Locale
2525
import java.util.concurrent.{Callable, TimeUnit}
2626

2727
import com.google.common.cache.CacheBuilder
28+
import com.google.common.util.concurrent.{ExecutionError, UncheckedExecutionException}
2829

2930
trait DateTimeFormatterHelper {
3031
protected def toInstantWithZoneId(temporalAccessor: TemporalAccessor, zoneId: ZoneId): Instant = {
@@ -63,10 +64,16 @@ object DateTimeFormatterHelper {
6364
}
6465

6566
def getFormatter(pattern: String, locale: Locale): DateTimeFormatter = {
66-
cache.get(
67-
(pattern, locale),
68-
new Callable[DateTimeFormatter]() {
69-
override def call = buildFormatter(pattern, locale)
70-
})
67+
try {
68+
cache.get(
69+
(pattern, locale),
70+
new Callable[DateTimeFormatter]() {
71+
override def call = buildFormatter(pattern, locale)
72+
})
73+
} catch {
74+
// Cache.get() may wrap the original exception.
75+
case e @ (_: UncheckedExecutionException | _: ExecutionError) =>
76+
throw e.getCause
77+
}
7178
}
7279
}

0 commit comments

Comments
 (0)