Octavi00 commented on PR #11426: URL: https://github.com/apache/gravitino/pull/11426#issuecomment-4655862492
@diqiu50 I spent some time revisiting the bug report and came to the conclusion it was due to an overly simple buildUri function inside of HTTPClient.java. I came to this conclusion by first acknowledging the fact that the issue happens after the CatalogConnectorManager starts, not before. So, in order to jump to DefaultOAuth2TokenProvider, which, after testing, worked fine, I went to GravitinoAuthProvider, which was alright as well. Then I moved to the scheduled path, and followed until I found a path for possible error: start() -> loadMetalake() -> retrieveMetalake() -> GravitinoClientBase.loadMetalake() -> restClient.get() -> HTTPClient.execute(). Within HTTPClient.execute() I found room for error. I saw that the argument request, the parameter within the call, was built from buildUri() within the file. I then scrolled to the buildUri() function and found it was only manually joining the parameters uri and path using the String.format() function, then simply returning it. So it was an unchecked URI that was then passed to HC5, which could return an NPE. My fix was to first validate the URI by making a separate URI variable requestUri, and building it. If its required properties were still null, scheme or host, then I would throw a RESTException stating such, otherwise I'd return it as expected. I didn't change the manually joining parameters to preserve already existing tests and code flow, while still addressing the issue. I also added one more unit test to ensure an invalid URI is handled before the execution, as was the issue I observed. Importantly, I haven't had the time to create my own Kubernetes environment to perfectly replicate the bug, as I'm newer to this repository, but I feel that I was correctly following the bug's trail, and I'm pretty confident in my solution. It'd be great if someone with the particular environment could test my proposal. Thank you -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
