Conversation
66b6815 to
fd6016a
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a thread-safe progress tracking mechanism for resumable uploads, consisting of the ResumableUploadProgressListener interface, the ResumableUploadStatus value class, and the UploadProgressTracker coordinator, along with comprehensive unit tests. Feedback on the changes suggests clearing the registered listeners list in UploadProgressTracker once a terminal state is reached to prevent potential memory leaks.
| @GuardedBy("lock") | ||
| private List<RegisteredListener> updateStatusLocked(ResumableUploadStatus newStatus) { | ||
| this.currentStatus = newStatus; | ||
| if (newStatus.getUploadUrl() != null && this.uploadSessionUrl == null) { | ||
| this.uploadSessionUrl = newStatus.getUploadUrl(); | ||
| } | ||
| return new ArrayList<>(this.listeners); | ||
| } |
There was a problem hiding this comment.
To prevent potential memory leaks and unnecessary resource retention, the list of registered listeners should be cleared once the tracker enters a terminal state (FINALIZED or FAILED). Since no further progress updates can occur after reaching a terminal state, holding onto the listeners (and potentially their enclosing classes or executors) is unnecessary.
@GuardedBy("lock")
private List<RegisteredListener> updateStatusLocked(ResumableUploadStatus newStatus) {
this.currentStatus = newStatus;
if (newStatus.getUploadUrl() != null && this.uploadSessionUrl == null) {
this.uploadSessionUrl = newStatus.getUploadUrl();
}
List<RegisteredListener> snapshot = new ArrayList<>(this.listeners);
if (newStatus.isTerminal()) {
this.listeners.clear();
}
return snapshot;
}fd6016a to
18db19d
Compare
4dfdd22 to
3794533
Compare
18db19d to
b44760b
Compare
3794533 to
497d777
Compare
b44760b to
25bba5f
Compare
497d777 to
a5ffaf3
Compare
25bba5f to
bafa84d
Compare
a5ffaf3 to
fc40846
Compare
bafa84d to
7b55d31
Compare
fc40846 to
6960f29
Compare
7b55d31 to
5f66ff4
Compare
6960f29 to
7d98c7b
Compare
5f66ff4 to
6648aca
Compare
7d98c7b to
a355e4a
Compare
6648aca to
e449f69
Compare
a355e4a to
c59321f
Compare
e449f69 to
e65339b
Compare
c59321f to
bf605a2
Compare
e65339b to
32dcea1
Compare
bf605a2 to
aacf3b6
Compare
32dcea1 to
c99edd0
Compare
aacf3b6 to
c36f0cd
Compare
c99edd0 to
06c48fe
Compare
c36f0cd to
17e0368
Compare
06c48fe to
75003f3
Compare
17e0368 to
9f3a73f
Compare
75003f3 to
cbdbd26
Compare
9f3a73f to
efea040
Compare
cbdbd26 to
5dad896
Compare
efea040 to
0e50e79
Compare
5dad896 to
3c7f4e9
Compare
0e50e79 to
2eb5a87
Compare
3c7f4e9 to
deed08d
Compare
|
|


Introduces
ResumableUploadStatus,UploadProgressListener, and thread-safeUploadProgressTracker. Tracks uploaded byte counts and state transitions across chunk attempts.