-
Notifications
You must be signed in to change notification settings - Fork 691
Description
Summary
For URIs which URI parser is unable to parse, it throws exception which results in remote address being null. When HttpMetricsRecorder interface methods are invoked in Kotlin environment, it results in NPE.
Code Flow
While resolving the path in HttpServerOperations object creation, if URI parser throws any exception due to parsing issue, remote address is coming as null due to connectionInfo being null.
Expected Behavior
Metrics recorder should be invoked successfully. Interface methods params should be marked as nullable so that the implementation could provide specific handling. This would be specific to Kotlin as the arguments are inferred as non-nullable.
Actual Behavior
Resulting in NPE as the interface methods params are non-nullable.
Steps to Reproduce
-
Create an implementation of
ChannelMetricsRecorder. -
Use any URI which URI parser couldn't resolve. eg -
http://localhost:8080/s=set&_method=__construct&method=*&filter[]=system -
When metrics recorder will invoke any of the interface methods requiring remote address, it will result in NPE in Kotlin.
Possible Solution
Mark methods as nullable so that Kotlin can infer the parameters as nullable and implementation could handle those gracefully.
Your Environment
Koltin Version: 1.6.10
reactor-netty-http: 1.0.18
- JVM version : JAVA 17
- OS and version : macOs Ventura 13.2
Stack trace
URI Parser
java.net.URISyntaxException: Illegal character in path at index 63: http://localhost:8080/s=set&_method=__construct&method=*&filter[]=system at java.net.URI$Parser.fail(URI.java:2974) ~[?:?] at java.net.URI$Parser.checkChars(URI.java:3145) ~[?:?] at java.net.URI$Parser.parseHierarchical(URI.java:3227) ~[?:?] at java.net.URI$Parser.parse(URI.java:3175) ~[?:?] at java.net.URI.<init>(URI.java:623) ~[?:?] at java.net.URI.create(URI.java:904) ~[?:?] at reactor.netty.http.HttpOperations.resolvePath(HttpOperations.java:389) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at reactor.netty.http.server.HttpServerOperations.<init>(HttpServerOperations.java:173) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at reactor.netty.http.server.HttpServerOperations.<init>(HttpServerOperations.java:148) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:213) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final]
Metrics recorder
io.netty.channel.AbstractChannelHandlerContext -- An exception 'java.lang.NullPointerException: Parameter specified as non-null is null: method com.apple.carrierservices.preauth.config.netty.HubbleHttpServerMetricsRecorder.incrementErrorsCount, parameter remoteAddress' [enable DEBUG level for full stacktrace] was thrown by a user handler's exceptionCaught() method while handling the following exception: java.lang.NullPointerException: Parameter specified as non-null is null: method com.apple.carrierservices.preauth.config.netty.HubbleHttpServerMetricsRecorder.recordDataReceived, parameter remoteAddress at com.apple.carrierservices.preauth.config.netty.HubbleHttpServerMetricsRecorder.recordDataReceived(HubbleHttpServerMetricsRecorder.kt) ~[classes!/:?] at reactor.netty.http.server.AbstractHttpServerMetricsHandler.recordRead(AbstractHttpServerMetricsHandler.java:183) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at reactor.netty.http.server.AbstractHttpServerMetricsHandler.channelRead(AbstractHttpServerMetricsHandler.java:151) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:266) ~[reactor-netty-http-1.0.18.jar!/:1.0.18] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.76.Final.jar!/:4.1.76.Final]