Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: npe because of clone is not thread safe in BreakpointInfo #323

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,13 @@ public void setEtag(String etag) {

public long getTotalOffset() {
long offset = 0;
ArrayList<BlockInfo> list = (ArrayList<BlockInfo>) ((ArrayList) blockInfoList).clone();

final int count = list.size();
for (int i = 0; i < count; i++) {
final BlockInfo info = list.get(i);
offset += info.getCurrentOffset();
final Object[] blocks = blockInfoList.toArray();
if (blocks != null) {
Jacksgong marked this conversation as resolved.
Show resolved Hide resolved
for (Object block : blocks) {
if (block instanceof BlockInfo) {
offset += ((BlockInfo) block).getCurrentOffset();
}
}
}
return offset;
}
Expand All @@ -138,9 +139,13 @@ public long getTotalLength() {
if (isChunked()) return getTotalOffset();

long length = 0;
ArrayList<BlockInfo> list = (ArrayList<BlockInfo>) ((ArrayList) blockInfoList).clone();
for (BlockInfo info : list) {
length += info.getContentLength();
final Object[] blocks = blockInfoList.toArray();
if (blocks != null) {
for (Object block : blocks) {
if (block instanceof BlockInfo) {
length += ((BlockInfo) block).getContentLength();
}
}
}

return length;
Expand Down