RingbufferStore does not support byte[] as type parameter.

Đang mở
#417 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@mmedenjak đang làm issue này rồi.

Từ ngày 4/5/2020.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

https://github.com/hazelcast/hazelcast-code-samples/blob/e640f3ea1c3659e954e4dcfc91f55079675314a5/distributed-collections/ringbufferstore/src/main/java/TheRingbufferBinaryStore.java#L11

Version:

3.4.11 ( Although I just checked the 4.x code and it has the same problem )

Description:

When implementing a RingbufferStore<byte[]> as in the example, when storeAll is invoked it will fail with a ClassCastException. This is because the RingbufferStoreWrapper converts the data into an Object array before trying to call the main RingBufferStore. An Object[] cannot be cast into an byte[][] so it fails to properly cast the data.

Example:

public class SimpleRingBufferStore implements RingbufferStore<byte[]>
{
  public void store(final long sequence, final byte[] data) {}
  public void storeAll(long firstItemSequence, byte[] [] items) {}
  public byte[] load(long sequence) { return new byte[0]; }
  public long getLargestSequence() { return 0L; }
}

var hazelcastInstance = ... // configure with ring buffer store and binary mode
var ringbuffer = hazelcastInstance .getRingbuffer("test_ringbuffer");

// This will fail internally
ringbuffer.addAllAsync(asList("A", "B", "C"), OverflowPolicy.FAIL)
   .get();

// This will work
ringbuffer.add("A");
ringbuffer.add("B");
ringbuffer.add("C");


Solution:

The solution seems to be change it to RingBufferStore<Object> and then casting it internally.

Ngôn ngữ chính
Java
Star
558
Fork
599
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

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 hazelcast/hazelcast-code-samples

Tất cả issue của hazelcast/hazelcast-code-samples

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.