Fix #129: Memory leak when setOptions() fails while accepting a new connection.
This commit is contained in:
parent
c6ef712503
commit
414b18e704
@ -211,7 +211,15 @@ public class ClientBootstrap extends Bootstrap {
|
|||||||
|
|
||||||
// Set the options.
|
// Set the options.
|
||||||
Channel ch = getFactory().newChannel(pipeline);
|
Channel ch = getFactory().newChannel(pipeline);
|
||||||
ch.getConfig().setOptions(getOptions());
|
boolean success = false;
|
||||||
|
try {
|
||||||
|
ch.getConfig().setOptions(getOptions());
|
||||||
|
success = true;
|
||||||
|
} finally {
|
||||||
|
if (!success) {
|
||||||
|
ch.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bind.
|
// Bind.
|
||||||
if (localAddress != null) {
|
if (localAddress != null) {
|
||||||
|
@ -185,8 +185,16 @@ public class ConnectionlessBootstrap extends Bootstrap {
|
|||||||
Channel ch = getFactory().newChannel(pipeline);
|
Channel ch = getFactory().newChannel(pipeline);
|
||||||
|
|
||||||
// Apply options.
|
// Apply options.
|
||||||
ch.getConfig().setPipelineFactory(getPipelineFactory());
|
boolean success = false;
|
||||||
ch.getConfig().setOptions(getOptions());
|
try {
|
||||||
|
ch.getConfig().setPipelineFactory(getPipelineFactory());
|
||||||
|
ch.getConfig().setOptions(getOptions());
|
||||||
|
success = true;
|
||||||
|
} finally {
|
||||||
|
if (!success) {
|
||||||
|
ch.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bind
|
// Bind
|
||||||
ChannelFuture future = ch.bind(localAddress);
|
ChannelFuture future = ch.bind(localAddress);
|
||||||
@ -290,7 +298,16 @@ public class ConnectionlessBootstrap extends Bootstrap {
|
|||||||
|
|
||||||
// Set the options.
|
// Set the options.
|
||||||
Channel ch = getFactory().newChannel(pipeline);
|
Channel ch = getFactory().newChannel(pipeline);
|
||||||
ch.getConfig().setOptions(getOptions());
|
boolean success = false;
|
||||||
|
try {
|
||||||
|
ch.getConfig().setPipelineFactory(getPipelineFactory());
|
||||||
|
ch.getConfig().setOptions(getOptions());
|
||||||
|
success = true;
|
||||||
|
} finally {
|
||||||
|
if (!success) {
|
||||||
|
ch.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bind.
|
// Bind.
|
||||||
if (localAddress != null) {
|
if (localAddress != null) {
|
||||||
|
@ -349,7 +349,11 @@ public class ServerBootstrap extends Bootstrap {
|
|||||||
ChannelHandlerContext ctx,
|
ChannelHandlerContext ctx,
|
||||||
ChildChannelStateEvent e) throws Exception {
|
ChildChannelStateEvent e) throws Exception {
|
||||||
// Apply child options.
|
// Apply child options.
|
||||||
e.getChildChannel().getConfig().setOptions(childOptions);
|
try {
|
||||||
|
e.getChildChannel().getConfig().setOptions(childOptions);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Channels.fireExceptionCaught(e.getChildChannel(), t);
|
||||||
|
}
|
||||||
ctx.sendUpstream(e);
|
ctx.sendUpstream(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user