Allow passing classloaders anywhere we use `getResource`
See original GitHub issue- https://github.com/http4s/http4s/blob/0f8ae7113f0afec89b695c34d94295d55c91de85/core/src/main/scala/org/http4s/StaticFile.scala#L40
- https://github.com/http4s/http4s/blob/0f8ae7113f0afec89b695c34d94295d55c91de85/core/src/main/scala/org/http4s/StaticFile.scala#L51
- https://github.com/http4s/http4s/blob/0f8ae7113f0afec89b695c34d94295d55c91de85/tomcat/src/main/scala/org/http4s/server/tomcat/TomcatBuilder.scala#L155
These assume that http4s and application resources come from the same classloader, which is not always the case. We should allow passing a custom classloader instead, defaulting to getClass.getClassLoader
.
The change itself is trivial. The main pain here will probably come from MiMa.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Loading resources using getClass().getResource()
Yes, I am using Eclipse, and it wasn't set up to copy resources. Have fixed that. The class is located in root/bin/<namespace>/MyClass and...
Read more >What are different ways to load classpath resources in Java?
currentThread().getContextClassLoader().getResource(resourceName): A ClassLoader can be passed (shared) when creating a new thread using Thread.
Read more >How to Load Resources from Classpath in Java with Example
The answer is by using java.lang.Class' getResource() and getResourceAsStream() method. These methods accept the path of resource as String and return URL and ......
Read more >Java - Read a file from resources folder - Mkyong.com
In Java, we can use getResourceAsStream or getResource to read a file or multiple files from a resources folder or root of the...
Read more >Difference Between Class.getResource() and ClassLoader ...
Now, let's see how we can get the resource using a Class instance. We can pass an absolute or relative path when locating...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is a smart idea.
Maybe #2158 would help, although if it’s just an addition of default parameters, it might not be so bad in current form. Just, as noted, not going to be binary compatible.
Either way, 0.21 is an opportunity to fix this.
@nigredo-tori yes, I missed that. Should be fixed by #3007