Conversation
1d1b1ca to
b6a2334
Compare
83b4b65 to
9ff252b
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors error handling and status tracking during resumable uploads by augmenting exceptions with the upload URL or endpoint to make them more actionable. It also simplifies synchronization in ResumableUploadChunkCoordinator, improves error messages for stream rewinding, and adds comprehensive unit tests. The review feedback highlights two critical issues: first, removing synchronization from closePayload() introduces a potential race condition on payloadClosed, which should be resolved using an explicit lock; second, recreating exceptions in augmentWithUrl discards the original stack trace, which should be preserved by copying it to the new exception instance.
| private @Nullable IOException closePayload() { | ||
| if (payloadClosed) { | ||
| return null; | ||
| } | ||
| payloadClosed = true; |
There was a problem hiding this comment.
Removing the lock from closePayload() introduces a potential race condition and visibility issues on the payloadClosed field. Since this is performance-sensitive code, prefer using an explicit lock over the synchronized keyword to protect the shared state while ensuring thread safety and visibility.
private @Nullable IOException closePayload() {
lock.lock();
try {
if (payloadClosed) {
return null;
}
payloadClosed = true;
} finally {
lock.unlock();
}References
- In performance-sensitive code, prefer using explicit locks over the 'synchronized' keyword to protect shared state while ensuring thread safety and visibility.
| if (augmented != t) { | ||
| for (Throwable suppressed : t.getSuppressed()) { | ||
| augmented.addSuppressed(suppressed); | ||
| } | ||
| payloadClosed = true; | ||
| } |
There was a problem hiding this comment.
When recreating the exception with the augmented message, the original stack trace of t is lost because a new exception instance is constructed and its stack trace is initialized to the current thread's execution point. To preserve the original stack trace for easier debugging, we should copy the stack trace from the original exception t to the augmented exception.
| if (augmented != t) { | |
| for (Throwable suppressed : t.getSuppressed()) { | |
| augmented.addSuppressed(suppressed); | |
| } | |
| payloadClosed = true; | |
| } | |
| if (augmented != t) { | |
| augmented.setStackTrace(t.getStackTrace()); | |
| for (Throwable suppressed : t.getSuppressed()) { | |
| augmented.addSuppressed(suppressed); | |
| } | |
| } |
b6a2334 to
cff442f
Compare
9ff252b to
ca9311c
Compare
cff442f to
7719368
Compare
ca9311c to
f4f204e
Compare
b437cfb to
fa4991c
Compare
f4f204e to
e88cc0e
Compare
fa4991c to
51c92a7
Compare
295cebb to
3689a54
Compare
51c92a7 to
befccca
Compare
3689a54 to
ff83e05
Compare
befccca to
087add0
Compare
ff83e05 to
f8af452
Compare
087add0 to
0f41372
Compare
f8af452 to
8310b51
Compare
0f41372 to
220c398
Compare
8310b51 to
1078304
Compare
220c398 to
51ee08e
Compare
1078304 to
49e3dcf
Compare
51ee08e to
72b1229
Compare
49e3dcf to
950274a
Compare
72b1229 to
af968ca
Compare
950274a to
ee73e46
Compare
af968ca to
9beb284
Compare
495ff31 to
eeca06d
Compare
f809bf6 to
9e21cac
Compare
eeca06d to
7876a69
Compare
9e21cac to
e59d549
Compare
7876a69 to
9c9b1b5
Compare
b5ca61e to
bd154f0
Compare
b50456d to
2aeb2f1
Compare
bd154f0 to
d1701a6
Compare
2aeb2f1 to
c4e12c5
Compare
d1701a6 to
0e9f9bc
Compare
c4e12c5 to
282993f
Compare
0e9f9bc to
8461e5c
Compare
282993f to
9a55379
Compare
8461e5c to
04958ce
Compare
9a55379 to
04213cd
Compare
04958ce to
b88c2ec
Compare
04213cd to
2635b58
Compare
b88c2ec to
a30c5f5
Compare
2635b58 to
afc3739
Compare
a30c5f5 to
999ba7b
Compare
afc3739 to
9d6f045
Compare
999ba7b to
ac5261f
Compare
9d6f045 to
469ce0d
Compare
ac5261f to
51ec823
Compare
…and stream requirements Augments terminal failure exceptions with the active upload session URL to aid debugging and session recovery. Clarifies error messages when a server committed offset falls below the buffer base offset.
|
|





Augments terminal failure exceptions with the active upload session URL to aid debugging and session recovery. Clarifies error messages when a server committed offset falls below the buffer base offset.