playframework/playframework — pull request #3406 by jlc (2014-09-15 10:05:46+00:00)
Title: Handle 'bundle' protocol in Resources.isDirectory. Fixes #3212

Within an OSGi container, URLs' protocol is "bundle://".

In order to detect if a resource is a directory, this fix
rely on the class loader's behavior, which differ between
the standalone JVM and within an OSGi environment.
Most notably, ClassLoader.getResource returns differently
when the resource's name end with a slash.

In a standard JVM, getResource doesn't care of ending slashes,
and return the URL of any existing resources. In an OSGi container
(tested with Apache Felix), ending slashe refers to a directory
(return null otherwise).

In order to test Resources.isDirectory when the protocol is "bundle://",
there are 2 options:
a) run the test within an OSGi container (using Pax Exam),
b) simulate the behavior of an OSGi class loader, which is the
implemented solution.