Skip to content

Commit

Permalink
Fixed BatchMessage serialization (NPE in size())
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Apr 23, 2024
1 parent 6b646f2 commit c2f9cef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/org/jgroups/BatchMessage.java
Expand Up @@ -122,7 +122,8 @@ public String toString() {
}

public int size() {
int retval=super.size() + Global.INT_SIZE + orig_src.serializedSize(); // length + src
int retval=super.size() + Global.INT_SIZE;
retval+=Util.size(orig_src);
if(msgs != null) {
for(int i=0; i < index; i++)
retval+=msgs[i].size() + Global.SHORT_SIZE; // type
Expand Down
1 change: 1 addition & 0 deletions src/org/jgroups/protocols/TransferQueueBundler.java
Expand Up @@ -137,6 +137,7 @@ public void run() {
}
}
catch(Throwable t) {
log.warn("%s: failed sending message: %s", transport.addr(), t);
}
}
}
Expand Down
Expand Up @@ -38,11 +38,15 @@ public void testSendMulticast() throws Exception {
MyReceiver<Message> r2=new MyReceiver<Message>().rawMsgs(true);
a.connect(BatchMessageTest.class.getSimpleName());
b.connect(BatchMessageTest.class.getSimpleName());
a.setReceiver(r1);
b.setReceiver(r2);
Util.waitUntilAllChannelsHaveSameView(2000, 100, a,b);
BatchMessage msg=new BatchMessage(null, 3);
for(int i=1; i <= 5; i++)
msg.add(new ObjectMessage(null, "hello-" + i));
System.out.print("-- sending multicast BatchMessage: ");
a.send(msg);
System.out.println(": done");
Util.waitUntil(2000, 100, () -> r1.size() == 1 && r2.size() == 1);
}

Expand Down

0 comments on commit c2f9cef

Please sign in to comment.