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

RingbufferStore does not support byte[] as type parameter. #417

Open
andrewfinnell opened this issue Apr 29, 2020 · 1 comment
Open

RingbufferStore does not support byte[] as type parameter. #417

andrewfinnell opened this issue Apr 29, 2020 · 1 comment
Assignees
Milestone

Comments

@andrewfinnell
Copy link

andrewfinnell commented Apr 29, 2020

public void storeAll(long firstItemSequence, byte[][] items) {

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.

@mmedenjak mmedenjak self-assigned this May 4, 2020
@mmedenjak mmedenjak added this to the 4.1 milestone May 4, 2020
@mmedenjak
Copy link
Contributor

Thank you for the report @andrewfinnell ! Do you mind sending a PR to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants