do not decrease netty buffer ref counter if 0
This commit is contained in:
parent
ab9cba9d99
commit
be220d2e78
8 changed files with 29 additions and 15 deletions
|
@ -1,3 +1,3 @@
|
|||
group = org.xbib
|
||||
name = net-http
|
||||
version = 4.8.1
|
||||
version = 4.8.2
|
||||
|
|
|
@ -6,9 +6,6 @@ dependencies {
|
|||
api project(':net-http-template-groovy')
|
||||
api project(':net-http-j2html')
|
||||
api libs.jdbc.query
|
||||
implementation libs.webjars.bootstrap
|
||||
implementation libs.webjars.jquery
|
||||
implementation libs.webjars.fontawesome
|
||||
testRuntimeOnly libs.net.bouncycastle
|
||||
}
|
||||
|
||||
|
@ -19,7 +16,7 @@ application {
|
|||
'-Duser.language=de',
|
||||
'-Duser.country=DE',
|
||||
'-Djava.awt.headless=true',
|
||||
'-Djava.util.logging.config.file=src/main/resources/logging.properties',
|
||||
'-Djava.util.logging.config.file=src/test/resources/logging.properties',
|
||||
'-Dapplication.home=src/main/application',
|
||||
'-Dapplication.profile=dev',
|
||||
'-Dapplication.name=web',
|
||||
|
|
|
@ -19,6 +19,7 @@ import io.netty.handler.codec.http2.HttpConversionUtil;
|
|||
import io.netty.handler.stream.ChunkedNioFile;
|
||||
import io.netty.handler.stream.ChunkedStream;
|
||||
import org.xbib.net.buffer.DataBuffer;
|
||||
import org.xbib.net.buffer.DefaultDataBufferFactory;
|
||||
import org.xbib.net.http.server.netty.buffer.NettyDataBuffer;
|
||||
import org.xbib.net.http.server.netty.buffer.NettyDataBufferFactory;
|
||||
import org.xbib.net.http.server.netty.http1.HttpPipelinedResponse;
|
||||
|
@ -48,7 +49,13 @@ public class HttpResponseBuilder extends BaseHttpResponseBuilder {
|
|||
|
||||
@Override
|
||||
public void reset() {
|
||||
if (dataBuffer != null) {
|
||||
dataBuffer.release();
|
||||
}
|
||||
super.reset();
|
||||
}
|
||||
|
||||
protected void resetDataBufferFactory() {
|
||||
this.dataBufferFactory = NettyDataBufferFactory.getInstance();
|
||||
}
|
||||
|
||||
|
|
|
@ -303,8 +303,12 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
|||
|
||||
@Override
|
||||
public void release() {
|
||||
boolean deallocated = byteBuf.release();
|
||||
logger.log(Level.FINEST, "released " + byteBuf + " deallocated = " + deallocated);
|
||||
if (byteBuf.refCnt() > 0) {
|
||||
boolean deallocated = byteBuf.release();
|
||||
logger.log(Level.FINEST, "released " + byteBuf + " deallocated = " + deallocated);
|
||||
} else {
|
||||
logger.log(Level.FINEST, "superfluous call to release() for " + byteBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -91,7 +91,7 @@ public class NettyDataBufferFactory implements DataBufferFactory {
|
|||
}
|
||||
int bufferCount = dataBuffers.size();
|
||||
if (bufferCount == 1) {
|
||||
return dataBuffers.get(0);
|
||||
return dataBuffers.getFirst();
|
||||
}
|
||||
CompositeByteBuf composite = byteBufAllocator.compositeBuffer(bufferCount);
|
||||
for (DataBuffer dataBuffer : dataBuffers) {
|
||||
|
|
|
@ -96,15 +96,24 @@ public abstract class BaseHttpResponseBuilder implements HttpResponseBuilder {
|
|||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the response, invalidate everything that was been written.
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
this.version = HttpVersion.HTTP_1_1;
|
||||
this.status = null; // must be undefined here
|
||||
this.headers = new HttpHeaders();
|
||||
this.trailingHeaders = new HttpHeaders();
|
||||
this.contentType = HttpHeaderValues.APPLICATION_OCTET_STREAM;
|
||||
this.dataBufferFactory = DefaultDataBufferFactory.getInstance();
|
||||
this.withConnectionCloseHeader = false; // tell client we want to keep the connection alive
|
||||
this.attributes = new BaseAttributes();
|
||||
resetDataBufferFactory();
|
||||
}
|
||||
|
||||
protected void resetDataBufferFactory() {
|
||||
// could be overridden
|
||||
this.dataBufferFactory = DefaultDataBufferFactory.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,5 +73,4 @@ public interface HttpResponseBuilder {
|
|||
void done();
|
||||
|
||||
void release();
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ dependencyResolutionManagement {
|
|||
version('netty-tcnative', '2.0.65.Final')
|
||||
version('datastructures', '5.1.1')
|
||||
version('net', '4.8.0')
|
||||
version('database', '2.2.0')
|
||||
library('netty-codec-http2', 'io.netty', 'netty-codec-http2').versionRef('netty')
|
||||
library('netty-handler', 'io.netty', 'netty-handler').versionRef('netty')
|
||||
library('netty-handler-proxy', 'io.netty', 'netty-handler-proxy').versionRef('netty')
|
||||
|
@ -17,9 +18,6 @@ dependencyResolutionManagement {
|
|||
library('jackson', 'com.fasterxml.jackson.core', 'jackson-databind').version('2.17.1')
|
||||
library('groovy-templates', 'org.apache.groovy', 'groovy-templates').versionRef('groovy')
|
||||
library('j2html', 'org.xbib', 'j2html').version('2.0.0')
|
||||
library('webjars-bootstrap', 'org.webjars', 'bootstrap').version('5.1.0')
|
||||
library('webjars-jquery', 'org.webjars', 'jquery').version('3.6.4')
|
||||
library('webjars-fontawesome', 'org.webjars', 'font-awesome').version('6.3.0')
|
||||
library('net', 'org.xbib', 'net').versionRef('net')
|
||||
library('net-mime', 'org.xbib', 'net-mime').versionRef('net')
|
||||
library('net-security', 'org.xbib', 'net-security').versionRef('net')
|
||||
|
@ -32,8 +30,8 @@ dependencyResolutionManagement {
|
|||
library('settings-datastructures-json', 'org.xbib', 'settings-datastructures-json').versionRef('datastructures')
|
||||
library('settings-datastructures-yaml', 'org.xbib', 'settings-datastructures-yaml').versionRef('datastructures')
|
||||
library('config', 'org.xbib', 'config').versionRef('datastructures')
|
||||
library('jdbc-query', 'org.xbib', 'jdbc-query').version('2.0.3')
|
||||
library('jdbc-connection-pool', 'org.xbib', 'jdbc-connection-pool').version('2.0.3')
|
||||
library('jdbc-query', 'org.xbib', 'jdbc-query').versionRef('database')
|
||||
library('jdbc-connection-pool', 'org.xbib', 'jdbc-connection-pool').versionRef('database')
|
||||
}
|
||||
testLibs {
|
||||
version('junit', '5.10.2')
|
||||
|
|
Loading…
Reference in a new issue