Bug 65778 - Don't create URL from string
Summary: Don't create URL from string
Status: REOPENED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Jasper (show other bugs)
Version: unspecified
Hardware: PC Mac OS X 10.1
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-01 22:55 UTC by Gael Lalire
Modified: 2022-01-11 18:48 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gael Lalire 2022-01-01 22:55:40 UTC
At least org.apache.jasper.compiler.Compiler Tomcat creates URL from string.

Instead of transforming an URL to a string to a new URL again, it is better to keep the original URL.

Maybe change JspServletWrapper.getDependants to Map<URL, Long> ?
Comment 1 Mark Thomas 2022-01-11 14:21:12 UTC
Not all dependencies are identified by URI. String is the lowest common denominator. 

Also, claims that an approach is "better" needs evidence to back up that claim.
Comment 2 Gael Lalire 2022-01-11 18:48:56 UTC
If you convert a URL to a string and then back to URL you will lose a specific URLHandler.
I'm using a specific URLHandler it allows me to open, read, and verify a jar against a checksum (sha512) once. The jar data is then kept in memory  channel.map(MapMode.PRIVATE, 0, size), so I'm sure that tomcat parsers are getting the signed data.

To get it working I put in the URL string something like m2://groupid/artifactid/version so it will reopen the file from .m2/repository but the data may not be correct.

If you want to keep other format you can create a class like this :

class URLorString {
  URL url;
  String string;

  getURL() {
    url != null ? url : new URL(string)
  }
}