Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public void injectBefore(Connection connection, String baseName, String name, Ch
Preconditions.checkNotNull(channelHandler, "The channelHandler cannot be null!");
try {
final Object channelWrapper = ReflectionUtil.getChannelWrapper(connection);
if (channelWrapper != null)
((Channel) ReflectionUtil.channelWrapperChannelField.get(channelWrapper)).pipeline().addBefore(baseName, name, channelHandler);
if (channelWrapper != null) {
ChannelPipeline pipeline = ((Channel) ReflectionUtil.channelWrapperChannelField.get(channelWrapper)).pipeline();
if (pipeline.get(name) != null) {
pipeline.remove(name);
}
pipeline.addBefore(baseName, name, channelHandler);
}
} catch (final Exception e) {
ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Exception occurred while injecting into netty pipeline", e);
}
Expand All @@ -32,8 +37,13 @@ public void injectAfter(Connection connection, String baseName, String name, Cha
Preconditions.checkNotNull(channelHandler, "The channelHandler cannot be null!");
try {
final Object channelWrapper = ReflectionUtil.getChannelWrapper(connection);
if (channelWrapper != null)
((Channel) ReflectionUtil.channelWrapperChannelField.get(channelWrapper)).pipeline().addAfter(baseName, name, channelHandler);
if (channelWrapper != null) {
ChannelPipeline pipeline = ((Channel) ReflectionUtil.channelWrapperChannelField.get(channelWrapper)).pipeline();
if (pipeline.get(name) != null) {
pipeline.remove(name);
}
pipeline.addAfter(baseName, name, channelHandler);
}
} catch (final Exception e) {
ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Exception occurred while injecting into netty pipeline", e);
}
Expand Down