Skip to content

Commit 87a535f

Browse files
committed
more robust getLatestRevision()
fixes #1756
1 parent bf0af47 commit 87a535f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/org/opensolaris/opengrok/web/PageConfig.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,16 @@ private String getLatestRevision() {
12101210
return null;
12111211
}
12121212

1213-
HistoryEntry he = hist.getHistoryEntries().get(0);
1213+
List<HistoryEntry> hlist = hist.getHistoryEntries();
1214+
if (hlist == null) {
1215+
return null;
1216+
}
1217+
1218+
if (hlist.size() == 0) {
1219+
return null;
1220+
}
1221+
1222+
HistoryEntry he = hlist.get(0);
12141223
if (he == null) {
12151224
return null;
12161225
}
@@ -1234,12 +1243,17 @@ public boolean isLatestRevision(String rev) {
12341243
*/
12351244
public String getLatestRevisionLocation() {
12361245
StringBuilder sb = new StringBuilder();
1246+
String revStr;
1247+
1248+
if ((revStr = getLatestRevision()) == null) {
1249+
return null;
1250+
}
12371251

12381252
sb.append(req.getContextPath());
12391253
sb.append(Prefix.XREF_P);
12401254
sb.append(Util.URIEncodePath(path));
12411255
sb.append("?r=");
1242-
sb.append(Util.URIEncode(getLatestRevision()));
1256+
sb.append(Util.URIEncode(revStr));
12431257

12441258
return sb.toString();
12451259
}

0 commit comments

Comments
 (0)