Shared static instance of DefaultDataBufferFactory

This commit is contained in:
Rossen Stoyanchev
2020-06-24 16:12:34 +01:00
parent 3a06622270
commit b16f6fa456
67 changed files with 184 additions and 273 deletions

View File

@@ -121,7 +121,7 @@ public class HttpHandlerConnectorTests {
}
private DataBuffer toDataBuffer(String body) {
return new DefaultDataBufferFactory().wrap(body.getBytes(UTF_8));
return DefaultDataBufferFactory.sharedInstance.wrap(body.getBytes(UTF_8));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ public class MockServerSpecTests {
@Override
protected WebHttpHandlerBuilder initHttpHandlerBuilder() {
return WebHttpHandlerBuilder.webHandler(exchange -> {
DefaultDataBufferFactory factory = new DefaultDataBufferFactory();
DefaultDataBufferFactory factory = DefaultDataBufferFactory.sharedInstance;
String text = exchange.getAttributes().toString();
DataBuffer buffer = factory.wrap(text.getBytes(StandardCharsets.UTF_8));
return exchange.getResponse().writeWith(Mono.just(buffer));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -161,7 +161,7 @@ public class MockServerTests {
private DataBuffer toDataBuffer(String value) {
byte[] bytes = value.getBytes(UTF_8);
return new DefaultDataBufferFactory().wrap(bytes);
return DefaultDataBufferFactory.sharedInstance.wrap(bytes);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class WebFilterTests {
public void testWebFilter() throws Exception {
WebFilter filter = (exchange, chain) -> {
DataBuffer buffer = new DefaultDataBufferFactory().allocateBuffer();
DataBuffer buffer = DefaultDataBufferFactory.sharedInstance.allocateBuffer();
buffer.write("It works!".getBytes(StandardCharsets.UTF_8));
return exchange.getResponse().writeWith(Mono.just(buffer));
};