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

Failure to process URL where path is nothing but "//" #948

Closed
rstoyanchev opened this issue Jan 13, 2020 · 8 comments
Closed

Failure to process URL where path is nothing but "//" #948

rstoyanchev opened this issue Jan 13, 2020 · 8 comments
Labels
type/bug A general bug

Comments

@rstoyanchev
Copy link
Contributor

After upgrading to Dysprosium snapshots, there is one test failure in the Spring Framework in a scenario where the path is nothing but a double slash, e.g. "http://localhost:8080//".

It results in the following:

java.lang.IllegalArgumentException: Expected authority at index 2: //
	at java.net.URI.create(URI.java:852) ~[?:1.8.0_222]
	at reactor.netty.http.HttpOperations.resolvePath(HttpOperations.java:300) ~[reactor-netty-0.9.3.BUILD-SNAPSHOT.jar:0.9.3.BUILD-SNAPSHOT]
	at reactor.netty.http.server.HttpServerOperations.<init>(HttpServerOperations.java:128) ~[reactor-netty-0.9.3.BUILD-SNAPSHOT.jar:0.9.3.BUILD-SNAPSHOT]
	at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:157) ~[reactor-netty-0.9.3.BUILD-SNAPSHOT.jar:0.9.3.BUILD-SNAPSHOT]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.44.Final.jar:4.1.44.Final]
...

This looks like it might be a side effect of refactoring for #926 in dc3fb4b.

@rstoyanchev rstoyanchev added type/bug A general bug status/need-triage A new issue that still need to be evaluated as a whole labels Jan 13, 2020
@violetagg violetagg removed the status/need-triage A new issue that still need to be evaluated as a whole label Jan 13, 2020
@violetagg violetagg added this to the 0.9.4.RELEASE milestone Jan 14, 2020
violetagg added a commit that referenced this issue Jan 14, 2020
violetagg added a commit that referenced this issue Feb 17, 2020
@qcastel
Copy link

qcastel commented Feb 19, 2020

I am currently hitting this issue in Spring Cloud gateway.
It can be reproduced with the following curl:

curl -k --proxy http://localhost:8500 https://example.com/test

(I am testing hoverfly in front of spring cloud gateway btw, https://hoverfly.io/, may help you reproduce the issue)

I thought I would try to see if it is fixed in 0.9.5 but unfortunately, there is still an NPE.

Seems like you re-introduce the bug two days ago, via 327e9b3 @violetagg

Here is the current stack trace:

java.lang.NullPointerException: null
	at reactor.netty.http.HttpOperations.resolvePath(HttpOperations.java:341)
	at reactor.netty.http.server.HttpServerOperations.<init>(HttpServerOperations.java:130)
	at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:155)

@violetagg
Copy link
Member

violetagg commented Feb 19, 2020

@qcastel can you provide more info?

I did the following:

Spring Gateway

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@Bean
	public RouteLocator myRoutes(RouteLocatorBuilder builder) {
		return builder.routes()
				.route(p -> p
						.path("/get")
						.uri("http://httpbin.org:80"))
				.build();
	}
}

Hoverfly started in capture mode

hoverctl start
hoverctl mode capture

Then Spring Gateway requested like below and the response is received

curl --proxy http://localhost:8500 http://localhost:8080/get
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip", 
    "Content-Length": "0", 
.....
}

Running with latest Reactor Netty 0.9.5.BUILD-SNAPSHOT

@qcastel
Copy link

qcastel commented Feb 19, 2020

Ok so indeed, that wasn't that obvious to reproduce the issue.

Did manage to reproduce it in isolation at the end, I shared a demo repo here: https://github.com/qcastel/reproduce-netty-npe

Essentially two factors are triggering this issue:
1 - you need to proxy to spring cloud gateway
2 - you need to proxy something under https

Thanks for looking at this issue btw!

@violetagg violetagg reopened this Feb 20, 2020
@violetagg
Copy link
Member

@qcastel I can reproduce it

violetagg added a commit that referenced this issue Feb 21, 2020
@violetagg
Copy link
Member

@qcastel I committed a fix - dfb71cf. It would be great if you can test 0.9.5.BUILD-SNAPSHOT.

@qcastel
Copy link

qcastel commented Feb 21, 2020

@violetagg Just tried on https://github.com/qcastel/reproduce-netty-npe and think the NPE is resolved now!

Although I do have another error:

curl: (56) Received HTTP code 404 from proxy after CONNECT

I also simplified the reproduction steps to not have hoverfly and directly hit Spring cloud gateway.

I guess I will raise a new ticket on Spring cloud gateway this time!

@violetagg
Copy link
Member

@qcastel so the new failure is not in Reactor Netty?

@qcastel
Copy link

qcastel commented Feb 21, 2020

Hard to tell, I don't get any logs this time. It could still be the netty rejecting the 'CONNECT' requests.
I raised it under spring-cloud/spring-cloud-gateway#1576
I reproduced the issue there (I simplified the reproduction steps btw) https://github.com/qcastel/reproduce-spring-cloud-gateway-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants