Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException is thrown when HAPROXY socket family is AF_UNSPEC #2984

Closed
ikhoon opened this issue Aug 10, 2020 · 0 comments · Fixed by #2985
Closed

NullPointerException is thrown when HAPROXY socket family is AF_UNSPEC #2984

ikhoon opened this issue Aug 10, 2020 · 0 comments · Fixed by #2985
Labels
Milestone

Comments

@ikhoon
Copy link
Contributor

ikhoon commented Aug 10, 2020

When Armeria Server receives a request from HAPROXY whose socket family is AF_UNSPEC, NPE is thrown.

0x0 : AF_UNSPEC : the connection is forwarded for an unknown, unspecified
    or unsupported protocol. The sender should use this family when sending
    LOCAL commands or when dealing with unsupported protocol families. The
    receiver is free to accept the connection anyway and use the real endpoint
    addresses or to reject it. The receiver should ignore address information.
  • Related stacktrace.
c.l.a.s.HttpServerPipelineConfigurator   : PROXY message V2: null:0 -> null:0 (next: [http])
etty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792)
netty-transport-native-epoll-4.1.51.Final-linux-x86_64.jar!/:4.1.51.Fin
l]
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) ~[netty-transport-native-epoll-4.1.51.Final-linux-x86_64.ja
!/:4.1.51.Final]
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-native-epoll-4.1.51.Final-linux-x86_64.jar!/:4.1.51.F
nal]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at io.ne
ty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.util.concurrent.FastThreadLo
alRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at java.lang.Thread.run(Thread.java:830) [?:
]
Caused by: java.lang.NullPointerException
	at io.netty.util.NetUtil.isValidIpV4Address(NetUtil.java:651) ~[netty-common-4.1.51.Final.ja
!/:4.1.51.Final]
	at io.netty.util.NetUtil.createByteArrayFromIpAddressString(NetUtil.java:371) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at com.lin
corp.armeria.server.HttpServerPipelineConfigurator$ProxiedPipelineConfigurator.decode(HttpServerPipelineConfigurator.java:375) ~[armeria-0.99.9.jar!/:?]
	at co
.linecorp.armeria.server.HttpServerPipelineConfigurator$ProxiedPipelineConfigurator.decode(HttpServerPipelineConfigurator.java:355) ~[armeria-0.99.9.jar!/:?]
t io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[netty-codec-4.1.51.Final.jar!/:4.1.51.Final]
	... 31 more
l]
	at io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:253) ~[netty-codec-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) ~[netty-codec-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440) ~[netty-codec-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[netty-codec-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152) ~[netty-handler-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792) ~[netty-transport-native-epoll-4.1.51.Final-linux-x86_64.jar!/:4.1.51.Final]
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) ~[netty-transport-native-epoll-4.1.51.Final-linux-x86_64.jar!/:4.1.51.Final]
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-native-epoll-4.1.51.Final-linux-x86_64.jar!/:4.1.51.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at java.lang.Thread.run(Thread.java:830) [?:?]
Caused by: java.lang.NullPointerException
	at io.netty.util.NetUtil.isValidIpV4Address(NetUtil.java:651) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at io.netty.util.NetUtil.createByteArrayFromIpAddressString(NetUtil.java:371) ~[netty-common-4.1.51.Final.jar!/:4.1.51.Final]
	at com.linecorp.armeria.server.HttpServerPipelineConfigurator$ProxiedPipelineConfigurator.decode(HttpServerPipelineConfigurator.java:375) ~[armeria-0.99.9.jar!/:?]
	at com.linecorp.armeria.server.HttpServerPipelineConfigurator$ProxiedPipelineConfigurator.decode(HttpServerPipelineConfigurator.java:355) ~[armeria-0.99.9.jar!/:?]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[netty-codec-4.1.51.Final.jar!/:4.1.51.Final]
	... 31 more
@ikhoon ikhoon added the defect label Aug 10, 2020
ikhoon added a commit to ikhoon/armeria that referenced this issue Aug 10, 2020
…ily is `AF_UNSPEC`

Motivation:

Armeria HAProxy handler considers that a HAProxyMessage contains addresses information.
However, if the address family is `AF_UNSPEC`, the addresses are null always.
From the HAProxy spec, the receiver can accept the connection or reject it.
There seems to be no harm ignoring the addresses information.

Modifications:

- Ignore proxied addresses information if AddressFamily is `AF_UNSPEC`

Result:

- HAProxy handler does not throw NullPointerException anymore.
- Fixes line#2984
@ikhoon ikhoon changed the title NullPointerException when HAPROXY socket family is AF_UNSPEC NullPointerException is thrown when HAPROXY socket family is AF_UNSPEC Aug 10, 2020
trustin pushed a commit that referenced this issue Aug 12, 2020
#2985)

…ily is `AF_UNSPEC`

Motivation:

Armeria HAProxy handler considers that a `HAProxyMessage` contains address information.
However, if the address family is `AF_UNSPEC`, the addresses are null always.
From the HAProxy spec, the receiver can accept the connection or reject it.
There seems to be no harm ignoring the addresses information.

Modifications:

- Ignore proxied addresses information if its address family is `AF_UNSPEC`

Result:

- HAProxy handler does not throw a `NullPointerException` anymore.
- Fixes #2984
@trustin trustin added this to the 1.0.0 milestone Aug 12, 2020
fmguerreiro pushed a commit to fmguerreiro/armeria that referenced this issue Sep 19, 2020
line#2985)

…ily is `AF_UNSPEC`

Motivation:

Armeria HAProxy handler considers that a `HAProxyMessage` contains address information.
However, if the address family is `AF_UNSPEC`, the addresses are null always.
From the HAProxy spec, the receiver can accept the connection or reject it.
There seems to be no harm ignoring the addresses information.

Modifications:

- Ignore proxied addresses information if its address family is `AF_UNSPEC`

Result:

- HAProxy handler does not throw a `NullPointerException` anymore.
- Fixes line#2984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants