The problem is fixed in JRebel (I can not play it with the current JRebel 6.1.1) - I think it is fixed from version 6.0.2 (December 23, 2014)
Fixed a bug due to which Spring ResourceHttpRequestHandler could not serve resources outside of webroot.
(JRebel Changelog https://zeroturnaround.com/software/jrebel/download/changelog/6-x/ )
For those who are interested in how they decided it:
I can only guess because it is strange. Spring 4.1.6 (that is, the version I used for the test) has an org.springframework.web.servlet.resource.PathResourceResolver class has a checkResource(Resource resource, Resource location) method:
protected boolean checkResource(Resource resource, Resource location) throws IOException { if (isResourceUnderLocation(resource, location)) { return true; } if (getAllowedLocations() != null) { for (Resource current : getAllowedLocations()) { if (isResourceUnderLocation(resource, current)) { return true; } } } return false; }
The first if : isResourceUnderLocation... is a method that checks whether or not a request to a resource is being accessed outside the configured resource folder
isResourceUnderLocation(Resource resource, Resource location) { ... resourcePath = ((ServletContextResource) resource).getPath(); locationPath = StringUtils.cleanPath(((ServletContextResource) location).getPath()); ... if (!resourcePath.startsWith(locationPath)) { return false; } ... }
When I use the debugger to check what is happening while the JRebel is active, something strange happens: when the JVM gets into the line if (isResourceUnderLocation(resource, location)) { , then the isResourceUnderLocation method isResourceUnderLocation not start!
So, I came to the conclusion that JRebel does some manipulation of bytecode to prevent validation (and the whole isResourceUnderLocation method).
source share