List iterators lose an item when loading the next page fails

Đang mở Phù hợp với người mới
#240 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu từ next() trong core/src/main/java/com/backblaze/b2/client/B2ListFilesIterableBase.java (khoảng dòng 43-58), nơi currentIndex được tăng trước khi advanceIfNeeded() có thể ném ngoại lệ; cùng một mẫu xuất hiện trong B2ListPartsIterableBase.java khoảng dòng 30-45. Viết một kiểm thử với client giả lập (mock) bị lỗi khi tải trang thứ hai, sau đó gọi lại next() sau khi bắt ngoại lệ để xác nhận phần tử bị mất. Hoàn thành khi phần tử được trả về hoặc thử lại đúng cách và kiểm thử đạt, cho cả hai iterator.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What happens

In next(), the iterator moves past the current item and then loads the next page if the current page is used up. If that page load fails, B2RuntimeException is thrown from next() and the item that was just taken is not returned. A caller that catches the exception and continues will not see that item, and the next next() call fails with an IllegalStateException instead of retrying the page.

Where

core/src/main/java/com/backblaze/b2/client/B2ListFilesIterableBase.java:43-58 (next() at about :50 increments currentIndex, then calls advanceIfNeeded()); the same pattern is in core/src/main/java/com/backblaze/b2/client/B2ListPartsIterableBase.java:30-45.

Why it matters

Impact: Wrong request or result (a listing silently misses an item for a caller that continues after the error), loud for the failed call. Severity: Medium, because it needs a page load that fails after retries and a caller that catches the error and keeps iterating (unusual), and a caller that stops on the first error is not affected.

How to check

Found by reading the code, not reproduced. Read next(): the value is read and currentIndex incremented before advanceIfNeeded() can throw. A test with a mocked client that fails on the second page load, and a caller that catches the exception and calls next() again, would show the missing item. Advancing lazily in hasNext() or returning the item before advancing would avoid it.

Version

Seen at v6.5.0. Present on the default branch: present.

Ngôn ngữ chính
Java
Star
103
Fork
23
Merge trung bình
5 ngày 8 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Backblaze/b2-sdk-java

Tất cả issue của Backblaze/b2-sdk-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.