Issue #437 - Avoid NPE on receiving empty message though MessageHandler.Partial
Minor updates to use features elsewhere in Jetty.
This commit is contained in:
parent
3630f623d8
commit
76476b6d28
|
@ -51,7 +51,7 @@ public class BinaryPartialMessage implements MessageAppender
|
|||
// Supported Partial<> Type #1: ByteBuffer
|
||||
if (msgWrapper.isMessageType(ByteBuffer.class))
|
||||
{
|
||||
partialHandler.onMessage(payload==null?ByteBuffer.allocate(0):
|
||||
partialHandler.onMessage(payload==null?BufferUtil.EMPTY_BUFFER:
|
||||
payload.slice(),isLast);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.jsr356;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -45,6 +45,8 @@ import org.junit.Before;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
/**
|
||||
* This class tests receiving of messages by different types of {@link MessageHandler}
|
||||
*/
|
||||
|
@ -57,11 +59,9 @@ public class MessageReceivingTest {
|
|||
private final String VERY_LONG_STRING;
|
||||
|
||||
public MessageReceivingTest() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 1024 * 1024; i++) {
|
||||
sb.append(i & 1);
|
||||
}
|
||||
VERY_LONG_STRING = sb.toString();
|
||||
byte raw[] = new byte[1024 * 1024];
|
||||
Arrays.fill(raw, (byte)'x');
|
||||
VERY_LONG_STRING = new String(raw, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
Loading…
Reference in New Issue