|
53 | 53 | * Each transport version should only be used in a single merged commit (apart from BwC versions copied from {@link Version}). |
54 | 54 | * <p> |
55 | 55 | * To add a new transport version, add a new constant at the bottom of the list that is one greater than the current highest version, |
56 | | - * ensure it has a unique id, and update the {@link #CURRENT} constant to point to the new version. |
| 56 | + * ensure it has a unique id, and update the {@link CurrentHolder#CURRENT} constant to point to the new version. |
57 | 57 | * <h2>Reverting a transport version</h2> |
58 | 58 | * If you revert a commit with a transport version change, you <em>must</em> ensure there is a <em>new</em> transport version |
59 | 59 | * representing the reverted change. <em>Do not</em> let the transport version go backwards, it must <em>always</em> be incremented. |
@@ -136,7 +136,18 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId |
136 | 136 | public static final TransportVersion V_8_500_010 = registerTransportVersion(8_500_010, "9818C628-1EEC-439B-B943-468F61460675"); |
137 | 137 | public static final TransportVersion V_8_500_011 = registerTransportVersion(8_500_011, "2209F28D-B52E-4BC4-9889-E780F291C32E"); |
138 | 138 |
|
139 | | - private static final TransportVersion CURRENT = findCurrent(V_8_500_011); |
| 139 | + private static class CurrentHolder { |
| 140 | + private static final TransportVersion CURRENT = findCurrent(V_8_500_011); |
| 141 | + |
| 142 | + // finds the pluggable current version, or uses the given fallback |
| 143 | + private static TransportVersion findCurrent(TransportVersion fallback) { |
| 144 | + var versionExtension = VersionExtension.load(); |
| 145 | + if (versionExtension == null) { |
| 146 | + return fallback; |
| 147 | + } |
| 148 | + return new TransportVersion(versionExtension.getCurrentTransportVersionId()); |
| 149 | + } |
| 150 | + } |
140 | 151 |
|
141 | 152 | /** |
142 | 153 | * Reference to the earliest compatible transport version to this version of the codebase. |
@@ -244,7 +255,7 @@ public static boolean isCompatible(TransportVersion version) { |
244 | 255 | * This should be the transport version with the highest id. |
245 | 256 | */ |
246 | 257 | public static TransportVersion current() { |
247 | | - return CURRENT; |
| 258 | + return CurrentHolder.CURRENT; |
248 | 259 | } |
249 | 260 |
|
250 | 261 | public boolean after(TransportVersion version) { |
@@ -272,15 +283,6 @@ public static TransportVersion fromString(String str) { |
272 | 283 | return TransportVersion.fromId(Integer.parseInt(str)); |
273 | 284 | } |
274 | 285 |
|
275 | | - // finds the pluggable current version, or uses the given fallback |
276 | | - private static TransportVersion findCurrent(TransportVersion fallback) { |
277 | | - var versionExtension = VersionExtension.load(); |
278 | | - if (versionExtension == null) { |
279 | | - return fallback; |
280 | | - } |
281 | | - return new TransportVersion(versionExtension.getCurrentTransportVersionId()); |
282 | | - } |
283 | | - |
284 | 286 | @Override |
285 | 287 | public int compareTo(TransportVersion other) { |
286 | 288 | return Integer.compare(this.id, other.id); |
|
0 commit comments