Skip to content

Commit 60eb2b4

Browse files
committed
Handle StorageExceptions when loading blobs.
* Fetching blobs and `ReadChannel`s can fail. Treat them as cache misses.
1 parent 12afb9d commit 60eb2b4

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In your `settings.gradle.kts` file add the following
88

99
```kotlin
1010
plugins {
11-
id("androidx.build.gradle.gcpbuildcache") version "1.0.0-alpha03"
11+
id("androidx.build.gradle.gcpbuildcache") version "1.0.0-alpha04"
1212
}
1313

1414
import androidx.build.gradle.gcpbuildcache.GcpBuildCache
@@ -36,7 +36,7 @@ If you are using Groovy, then you should do the following:
3636

3737
```groovy
3838
plugins {
39-
id("androidx.build.gradle.gcpbuildcache") version "1.0.0-alpha03"
39+
id("androidx.build.gradle.gcpbuildcache") version "1.0.0-alpha04"
4040
}
4141
4242
import androidx.build.gradle.gcpbuildcache.GcpBuildCache

RELEASE-NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release notes for GCP backed Gradle Remote Cache
22

3+
## 1.0.0-alpha04
4+
5+
- Handles exceptions when fetching `BlobInfo`s and `ReadChannel`s from the storage service.
6+
37
## 1.0.0-alpha03
48

59
- Fixes issue [19](https://github.com/androidx/gcp-gradle-build-cache/issues/19).

gcpbuildcache/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ gradlePlugin {
5454
}
5555

5656
group = "androidx.build.gradle.gcpbuildcache"
57-
version = "1.0.0-alpha03"
57+
version = "1.0.0-alpha04"
5858

5959
testing {
6060
suites {

gcpbuildcache/src/main/kotlin/androidx/build/gradle/gcpbuildcache/GcpStorageService.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ internal class GcpStorageService(
105105

106106
private fun load(storage: StorageOptions?, blobId: BlobId): ReadChannel? {
107107
if (storage == null) return null
108-
val blob = storage.service.get(blobId) ?: return null
109-
val reader = blob.reader()
110-
// We don't expect to store objects larger than Int.MAX_VALUE
111-
reader.setChunkSize(blob.size.toInt())
112-
return reader
108+
return try {
109+
val blob = storage.service.get(blobId) ?: return null
110+
val reader = blob.reader()
111+
// We don't expect to store objects larger than Int.MAX_VALUE
112+
reader.setChunkSize(blob.size.toInt())
113+
reader
114+
} catch (storageException: StorageException) {
115+
logger.debug("Unable to load Blob ($blobId)", storageException)
116+
null
117+
}
113118
}
114119

115120
private fun store(storage: StorageOptions?, blobId: BlobId, contents: ByteArray): Boolean {

0 commit comments

Comments
 (0)