Skip to content

Commit

Permalink
Fix build error when revision is shorter than 8 chars
Browse files Browse the repository at this point in the history
It will through ArrayOutOfBoundException if we build alluxio in a node
which have no git installed, and the `VERSION` would be shorter than 8,
even empty string, so substring(8) cannot work anymore.

This PR check there are more than 8 chars in the `VERSION` first,
otherwise, do not cut the `VERSION` string.

pr-link: #16888
change-id: cid-4e02cc9214317d86bba9d00a6121c5f013dd3255
  • Loading branch information
maobaolong committed Feb 26, 2023
1 parent 7ee4b74 commit c4b9ecf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/common/src/main/java/alluxio/RuntimeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public final class RuntimeConstants {
}
}

public static final String REVISION_SHORT = ProjectConstants.REVISION.substring(0, 8);
public static final String REVISION_SHORT = ProjectConstants.REVISION.length() > 8
? ProjectConstants.REVISION.substring(0, 8) : ProjectConstants.REVISION;
public static final String VERSION_AND_REVISION_SHORT =
VERSION + "-" + REVISION_SHORT;

Expand Down

0 comments on commit c4b9ecf

Please sign in to comment.