xiaqi1210 commented on PR #603: URL: https://github.com/apache/skywalking-java/pull/603#issuecomment-1705954760
> > Also, I think new URL() is a very heavy operation, while substring is more lightweight, which should also improve performance. > > You could propose a new solution, but substring is not an easy way to resolve URL always correctly. First, the HTTP URL specification is mentioned in [RFC1738](https://www.rfc-editor.org/rfc/rfc1738.txt) (3.3. HTTP), with the format as follows: ``` http://<host>:<port>/<path>?<searchpart> ``` There won't be '/' in host and port, so finding the first '/' after "//" and taking the substring after should always work. The only special case is: http://<host>:<port>, where the first '/' is not found, then the default uri=/ can be used. I can't think of any other special cases. On the other hand, for invalid URL scenarios, I don't think it's important to validate if the URL is valid before createSpan, because an invalid URL would definitely throw an exception when making the HTTP request, and the error span would be logged in `handleMethodException`. Also, invalid HTTP URLs should be very rare cases, so doing it this way wouldn't have much impact on performance either. -- 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]
