Add ByteString.emptyByteString to Java API (#26931)

* Add ByteString.emptyByteString to Java API

To work around https://github.com/scala/bug/issues/11509

* Add note to 2.6 migration document
This commit is contained in:
Arnout Engelen 2019-05-16 14:02:49 +02:00 committed by GitHub
parent b399e728a2
commit 7b20b89ce0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 9 deletions

View file

@ -19,6 +19,9 @@ import akka.io.UdpConnected;
import akka.io.UdpConnectedMessage;
import akka.io.UdpSO;
import akka.util.ByteString;
import static akka.util.ByteString.emptyByteString;
// #imports
public class UdpConnectedDocTest {
@ -79,7 +82,7 @@ public class UdpConnectedDocTest {
builder.matchEquals(
"send",
x -> {
ByteString data = ByteString.empty();
ByteString data = emptyByteString();
// #send
connectionActor.tell(UdpConnectedMessage.send(data), getSelf());
// #send

View file

@ -25,6 +25,7 @@ import akka.stream.javadsl.*;
import akka.stream.stage.*;
import akka.util.ByteIterator;
import akka.util.ByteString;
import static akka.util.ByteString.emptyByteString;
import akka.util.ByteStringBuilder;
import static org.junit.Assert.assertArrayEquals;
@ -156,7 +157,7 @@ public class BidiFlowDocTest extends AbstractJavaTest {
return new GraphStageLogic(shape) {
// this holds the received but not yet parsed bytes
private ByteString stash = ByteString.empty();
private ByteString stash = emptyByteString();
// this holds the current message length or -1 if at a boundary
private int needed = -1;

View file

@ -13,6 +13,7 @@ import akka.stream.javadsl.Source;
import akka.stream.stage.*;
import akka.testkit.javadsl.TestKit;
import akka.util.ByteString;
import static akka.util.ByteString.emptyByteString;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -78,7 +79,7 @@ public class RecipeByteStrings extends RecipeTest {
@Override
public GraphStageLogic createLogic(Attributes inheritedAttributes) {
return new GraphStageLogic(shape) {
private ByteString buffer = ByteString.empty();
private ByteString buffer = emptyByteString();
{
setHandler(
@ -149,7 +150,7 @@ public class RecipeByteStrings extends RecipeTest {
assertTrue(chunk.size() <= 2);
}
ByteString sum = ByteString.empty();
ByteString sum = emptyByteString();
for (ByteString chunk : chunks) {
sum = sum.concat(chunk);
}
@ -244,7 +245,7 @@ public class RecipeByteStrings extends RecipeTest {
.runWith(Sink.seq(), mat)
.toCompletableFuture()
.get(3, TimeUnit.SECONDS);
ByteString acc = ByteString.empty();
ByteString acc = emptyByteString();
for (ByteString b : got) {
acc = acc.concat(b);
}

View file

@ -12,6 +12,7 @@ import akka.stream.javadsl.Compression;
import akka.stream.javadsl.Source;
import akka.testkit.javadsl.TestKit;
import akka.util.ByteString;
import static akka.util.ByteString.emptyByteString;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -51,7 +52,7 @@ public class RecipeDecompress extends RecipeTest {
ByteString decompressedData =
decompressedStream
.runFold(ByteString.empty(), ByteString::concat, mat)
.runFold(emptyByteString(), ByteString::concat, mat)
.toCompletableFuture()
.get(1, TimeUnit.SECONDS);
String decompressedString = decompressedData.utf8String();