1919package org .apache .hadoop .hbase .client ;
2020
2121import java .io .IOException ;
22- import java .util .Date ;
22+ import java .time .Instant ;
23+ import java .time .format .DateTimeFormatter ;
2324import java .util .List ;
25+ import java .util .StringJoiner ;
2426
27+ import org .apache .commons .lang3 .StringUtils ;
2528import org .apache .yetus .audience .InterfaceAudience ;
2629
2730/**
@@ -41,24 +44,34 @@ public RetriesExhaustedException(final String msg, final IOException e) {
4144 }
4245
4346 /**
44- * Datastructure that allows adding more info around Throwable incident.
47+ * Data structure that allows adding more info around Throwable incident.
4548 */
4649 @ InterfaceAudience .Private
4750 public static class ThrowableWithExtraContext {
48- private final Throwable t ;
49- private final long when ;
51+ private final Throwable throwable ;
52+ private final long whenAsEpochMilli ;
5053 private final String extras ;
5154
52- public ThrowableWithExtraContext (final Throwable t , final long when ,
55+ public ThrowableWithExtraContext (final Throwable throwable , final long whenAsEpochMilli ,
5356 final String extras ) {
54- this .t = t ;
55- this .when = when ;
57+ this .throwable = throwable ;
58+ this .whenAsEpochMilli = whenAsEpochMilli ;
5659 this .extras = extras ;
5760 }
5861
5962 @ Override
6063 public String toString () {
61- return new Date (this .when ).toString () + ", " + extras + ", " + t .toString ();
64+ final StringJoiner joiner = new StringJoiner (", " );
65+ if (whenAsEpochMilli != 0 ) {
66+ joiner .add (DateTimeFormatter .ISO_INSTANT .format (Instant .ofEpochMilli (whenAsEpochMilli )));
67+ }
68+ if (StringUtils .isNotEmpty (extras )) {
69+ joiner .add (extras );
70+ }
71+ if (throwable != null ) {
72+ joiner .add (throwable .toString ());
73+ }
74+ return joiner .toString ();
6275 }
6376 }
6477
@@ -83,7 +96,7 @@ public RetriesExhaustedException(final String callableVitals, int numTries,
8396 public RetriesExhaustedException (final int numRetries ,
8497 final List <ThrowableWithExtraContext > exceptions ) {
8598 super (getMessage (numRetries , exceptions ),
86- exceptions .isEmpty ()? null : exceptions .get (exceptions .size () - 1 ).t );
99+ exceptions .isEmpty ()? null : exceptions .get (exceptions .size () - 1 ).throwable );
87100 }
88101
89102 private static String getMessage (String callableVitals , int numTries ,
0 commit comments