Skip to content

Commit 98b0679

Browse files
committed
Make changes backwards compatible
Add '@Deprecation' and '@Preview' annotations to make the changes backwards compatible and prepare for a transition to the cached behavior as default. This explicitly leaves the variant for re-fetching assets under a different name.
1 parent d881bf6 commit 98b0679

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/main/java/org/kohsuke/github/GHRelease.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,38 @@ public GHAsset uploadAsset(String filename, InputStream stream, String contentTy
251251
}
252252

253253
/**
254-
* Gets assets.
254+
* Get the cached assets.
255255
*
256256
* @return the assets
257+
*
258+
* @deprecated This should be the default behavior of {@link #getAssets()} in a future release. This method is
259+
* introduced in addition to enable a transition to using cached asset information while keeping the
260+
* existing logic in place for backwards compatibility.
257261
*/
258-
public List<GHAsset> getAssets() {
262+
@Deprecated
263+
@Preview
264+
public List<GHAsset> getCachedAssets() {
259265
return assets;
260266
}
261267

262268
/**
263269
* Re-fetch the assets of this release.
264-
*
270+
*
271+
* @return the assets
272+
* @throws IOException
273+
* the io exception
274+
* @deprecated The behavior of this method will change in a future release. It will then provide cached assets as
275+
* provided by {@link #getCachedAssets()}. Use {@link #fetchAssets()} instead to fetch up-to-date
276+
* information of assets.
277+
*/
278+
@Deprecated
279+
public List<GHAsset> getAssets() throws IOException {
280+
return fetchAssets();
281+
}
282+
283+
/**
284+
* Re-fetch the assets of this release.
285+
*
265286
* @return the assets
266287
* @throws IOException
267288
* the io exception

src/test/java/org/kohsuke/github/LifecycleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ private void updateAsset(GHRelease release, GHAsset asset) throws IOException {
5050

5151
private void deleteAsset(GHRelease release, GHAsset asset) throws IOException {
5252
asset.delete();
53-
assertEquals(0, release.getAssets().size());
53+
assertEquals(0, release.getCachedAssets().size());
5454
}
5555

5656
private GHAsset uploadAsset(GHRelease release) throws IOException {
5757
GHAsset asset = release.uploadAsset(new File("LICENSE.txt"), "application/text");
5858
assertNotNull(asset);
59-
List<GHAsset> cachedAssets = release.getAssets();
59+
List<GHAsset> cachedAssets = release.getCachedAssets();
6060
assertEquals(0, cachedAssets.size());
6161
List<GHAsset> assets = release.fetchAssets();
6262
assertEquals(1, assets.size());

0 commit comments

Comments
 (0)