Skip to content

Commit a4176e8

Browse files
committed
ATLAS-5070: Startup failure due to NPE in IndexRecoveryService when atlas.index.recovery.start.time is unset
1 parent b45b496 commit a4176e8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

repository/src/main/java/org/apache/atlas/repository/graph/IndexRecoveryService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.atlas.repository.graphdb.AtlasVertex;
2929
import org.apache.atlas.service.Service;
3030
import org.apache.commons.configuration.Configuration;
31+
import org.apache.commons.lang.StringUtils;
3132
import org.apache.commons.lang.math.NumberUtils;
3233
import org.slf4j.Logger;
3334
import org.slf4j.LoggerFactory;
@@ -132,12 +133,13 @@ private long getRecoveryStartTimeFromConfig(Configuration config) {
132133
long ret = 0L;
133134

134135
try {
135-
String time = config.getString(SOLR_INDEX_RECOVERY_CONFIGURED_START_TIME);
136-
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
136+
String time = config.getString(SOLR_INDEX_RECOVERY_CONFIGURED_START_TIME);
137+
if (StringUtils.isNotBlank(time)) {
138+
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
139+
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
137140

138-
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
139-
140-
ret = dateFormat.parse(time).toInstant().toEpochMilli();
141+
ret = dateFormat.parse(time).toInstant().toEpochMilli();
142+
}
141143
} catch (Exception e) {
142144
LOG.error("Error fetching: {}", SOLR_INDEX_RECOVERY_CONFIGURED_START_TIME, e);
143145
}

0 commit comments

Comments
 (0)