Commit Graph

458 Commits

Author SHA1 Message Date
Phillip Webb
798522d890 Format with Eclipse Oxygen SR2 2018-02-08 15:46:49 -08:00
Spring Buildmaster
6414b42335 Next Development Version 2018-01-30 23:29:33 +00:00
Stephane Nicoll
397d3e85e8 Fix Windows build
Closes gh-11459
2018-01-02 15:45:43 +01:00
Douglas Cardoso
feecc27677 Log inaccessible file in RandomAccessDataFile
Closes gh-11401
2017-12-28 11:25:51 +01:00
dreis2211
d5370e6852 Precompile current dir pattern in Handler
Closes gh-11321
2017-12-12 12:54:01 +00:00
dreis2211
37437a0fe2 Avoid allocations from lower-casing spec in JAR Handler
Closes gh-11314
2017-12-11 23:34:18 +01:00
Andy Wilkinson
a491727b7c Avoid creating unnecessary garbage during URL normalization
Closes gh-11207
2017-11-29 20:33:02 +00:00
Spring Buildmaster
df2ae7aa19 Next Development Version 2017-11-28 09:55:46 +00:00
Johnny Lim
4979af9fa5 Remove unnecessary assignments
Closes gh-10805
2017-10-29 14:07:00 +01:00
Spring Buildmaster
c0f9f64776 Next Development Version 2017-10-16 12:36:43 +00:00
Spring Buildmaster
30eb937a83 Next Development Version 2017-09-12 10:54:22 +00:00
Andy Wilkinson
7a87c69dd0 Normalize spec when creating jar URL by removing /../ and /./
Previously when Handler was creating a URL from a context URL and a
spec, any occurrances of /../ or /./ in the spec would be left as-is.
This differed from the JDK's Handler implementation which normalizes
the URL by modifying the path to remove any occurrences of /../ or
/./

This commit updates our Handler implementation to align it with the
JDK's. Tests have been added to assert that, given the same inputs,
the two Handler classes produce the same output.

Closes gh-9917
2017-08-03 19:48:58 +01:00
Andy Wilkinson
b7ac5f2eb2 Polish "Make JarURLConnection return entry's last modified time"
Closes gh-9893
2017-07-28 15:41:34 +01:00
rostislav.dudka
7c7259beec Make JarURLConnection return entry's last modified time
See gh-9893
2017-07-28 15:41:29 +01:00
Spring Buildmaster
17a5bb0be4 Next development version 2017-07-27 08:00:21 +00:00
Spring Buildmaster
41c5c0e7c9 Next development version 2017-07-26 08:30:55 +00:00
Phillip Webb
28dad44e2d Be defensive about JUL calls from JAR Handler
Update nested JAR support to only obtain JUL loggers when absolutely
necessary and to defensively deal with failures.

Prior to this commit it was not possible to override
`java.util.logging.manager` to use a nested JAR as the logger
implementation.

Fixes gh-9848
2017-07-24 12:54:24 -07:00
Phillip Webb
aa57ca7e18 Polish 2017-07-06 16:53:04 -07:00
Andy Wilkinson
2d3bcae4e1 Make JarURLConnection return entry's length from getContentLengthLong()
Closes gh-9484
2017-06-12 13:46:59 +01:00
Spring Buildmaster
05d4d0281c Next Development Version 2017-06-08 12:47:16 +00:00
Spring Buildmaster
88e43c8421 Next Development Version 2017-06-08 09:52:43 +00:00
Andy Wilkinson
5c708ae712 Merge branch '1.4.x' into 1.5.x 2017-06-01 11:04:23 +01:00
Andy Wilkinson
5b4f9edc86 Restore original TCCL in PropertiesLauncherTests
Calling launch of PropertiesLauncherTests sets the thread context
class loader to an instance of LaunchedURLClassLoader. To avoid this
class loader being used beyond the scope of the test and launcher
that created it, this commit updates PropertiesLauncherTests to
capture the TCCL before each test and restore it after each test.

Closes gh-9378
2017-06-01 10:58:00 +01:00
Andy Wilkinson
c22230a418 Try making FilePool static to fix the Mockito problem on Bamboo 2017-05-31 23:24:03 +01:00
Andy Wilkinson
e11b7aff08 Ensure that file is released back to pool when seek fails
Closes gh-9370
2017-05-31 21:50:05 +01:00
Andy Wilkinson
f7127e5522 Ensure that closing a JarFile closes all underlying resources
Closes gh-8871
2017-05-23 20:42:59 +01:00
Stephane Nicoll
f8e1345b75 Unify versions used in integration tests
This commit makes sure the integration tests use the same versions as
the one managed by `spring-boot-dependencies` (including Maven plugins).

Closes gh-8947
2017-05-09 09:36:21 +02:00
Spring Buildmaster
9768b0a8c2 Next Development Version 2017-04-21 08:32:01 +00:00
Spring Buildmaster
d719d2cbbc Next Development Version 2017-04-20 12:46:19 +00:00
Dave Syer
14638e67bc Extended PropertiesLauncher class location logic
Update `PropertiesLauncher` so that classes can be loaded outside of
`BOOT-INF/classes`. You can use a subdirectory, or the root directory
of an external jar (but not the parent archive to avoid issues
with agents and awkward delegation models).

Fixes gh-8480
Closes gh-8486
2017-04-19 22:18:12 -07:00
Phillip Webb
ad38776de3 Polish 2017-04-04 09:48:10 -07:00
Phillip Webb
ddcb5ee328 Polish 2017-04-04 09:36:27 -07:00
Andy Wilkinson
c55bfb00b1 Merge branch '1.4.x' into 1.5.x 2017-04-04 11:31:34 +01:00
Andy Wilkinson
456327260b Fail fast when a Zip64 jar is encountered
Previously, jars (either top-level or nested) in Zip64 format were
treated as normal jar files. This would lead to a failure later on
when an attempt was made to read an entry from the file.

This commit updates the loader to fail fast when it encounters a
Zip64 jar file. Such files are identified by the number of entries
in the central directory end record being 0xFFFF.

Closes gh-8735
2017-04-04 11:31:18 +01:00
Stephane Nicoll
d8e90af3bf Merge branch '1.4.x' into 1.5.x 2017-03-28 10:27:14 +02:00
dreis
1266642aba Fix test assertions
Closes gh-8660
2017-03-28 10:26:25 +02:00
Andy Wilkinson
e6cfb4e5fb Improve diagnostics when reading a nested jar throws a runtime exception
Previously, only IOExceptions were caught and wrapped in a new
IOException that included the name of the nested entry that was
being read.

Following this commit, any Exception is caught and wrapped so that the
problematic entry can be identified in more failure scenarios.

Closes gh-8711
2017-03-24 10:32:16 +00:00
Spring Buildmaster
d23fa24340 Next Development Version 2017-03-03 16:18:26 +00:00
Spring Buildmaster
2a83e80a9b Next Development Version 2017-03-03 14:39:21 +00:00
Andy Wilkinson
6673d8eebc Polish "Allow loader.path to refer to nested jars"
Closes gh-8334
Closes gh-8465
2017-03-02 17:29:45 +00:00
Dave Syer
3701cce88f Allow loader.path to refer to nested jars
Previously, each entry in loader.path could only refer to a standard
jar file. Refering to such a jar would add all of the classes in
the root of the jar to the class path.

This commit adds support for referencing a directory within a jar file
that contains one or more nested jars. For example:

$ java -jar -Dloader.path='jar:file:./lib.jar/!BOOT-INF/lib' my.jar

This will add all of the classes in all of that jars in the
BOOT-INF/lib directory of lib.jar to the class path.

See gh-8334
2017-03-02 16:49:24 +00:00
Andy Wilkinson
b36c8a7c24 Polish "Tighten up PropertiesLauncher's contract"
See gh-8346
Closes gh-7221
2017-03-02 11:19:48 +00:00
Dave Syer
e4c807b884 Tighten up PropertiesLauncher's contract
The main changes are:

- Switch to `loader.properties` instead of `application.properties`
- Search for `loader.properties` in `loader.home` as well as in
  the classpath
- Placeholder replacements in MANIFEST.MF (using `loader.properties`
  or system/env vars)

See gh-7221
Closes gh-8346
2017-03-02 11:19:48 +00:00
Spring Buildmaster
5c12500366 Next Development Version 2017-01-30 20:10:13 +00:00
Spring Buildmaster
a2696bf873 Next Development Version 2017-01-30 11:40:24 +00:00
Spring Buildmaster
ed1ce140c0 Next Development Version 2017-01-26 14:20:39 +00:00
Stephane Nicoll
505e7f75ea Polish contribution
Closes gh-8089
2017-01-25 11:01:53 +01:00
dreis
d58f38f6f6 Use String.replace() with single char if possible
See gh-8089
2017-01-25 11:01:52 +01:00
Stephane Nicoll
551bfb2c60 Polish contribution
Closes gh-8103
2017-01-25 11:01:52 +01:00
Johnny Lim
32f9e90de5 Replace 'String.length() == 0' with 'String.isEmpty()'
See gh-8103
2017-01-25 11:01:52 +01:00
dreis
cee576b8b2 Reduce memory footprint of AsciiBytes.hashCode
Update `AsciiBytes.hashCode(int hash, String string)` so that it no
longer copies the backing array of the string.

Closes gh-7851
2017-01-03 15:36:11 -08:00
Phillip Webb
aacf5d660f Update copyright year for changed files 2016-12-30 11:53:51 -08:00
Spring Buildmaster
9057f9ae1f Next development version 2016-12-23 00:15:23 +00:00
Johnny Lim
e12b4a944f Polish 2016-12-21 20:18:04 -08:00
Phillip Webb
6121208cbb Polish formatting 2016-12-19 12:47:03 -08:00
Phillip Webb
4b9cba351b Merge branch '1.4.x' into 1.5.x 2016-12-19 12:36:57 -08:00
Phillip Webb
bd74c3d327 Polish formatting 2016-12-19 12:25:09 -08:00
Andy Wilkinson
53287eadf6 Merge branch '1.4.x' into 1.5.x 2016-12-08 11:38:13 +00:00
Andy Wilkinson
2d8344d46d Ensure that JarLauncher doesn't cause root jar to be on class path twice
Closes gh-7595
2016-12-08 11:34:22 +00:00
Oscar Utbult
3a7969b8bb Remove redundant StringBuilder
Closes gh-7538
2016-12-01 12:11:04 +01:00
Oscar Utbult
fabe35fdc4 Remove redundant toString() invocation
Closes gh-7527
2016-11-30 08:23:03 +01:00
Stephane Nicoll
06e44c71ec Merge branch '1.4.x' into 1.5.x 2016-11-29 08:02:50 +01:00
Oscar Utbult
88b83a909c Remove redundant toString() invocation
Closes gh-7510
2016-11-29 08:01:27 +01:00
Phillip Webb
5ed00b3501 Merge branch '1.4.x' into 1.5.x 2016-11-28 15:27:07 -08:00
Phillip Webb
357d072a60 Polish 2016-11-28 15:14:46 -08:00
Andy Wilkinson
655ab9871b Merge branch '1.4.x' into 1.5.x 2016-11-23 14:04:59 +00:00
Andy Wilkinson
5e79657d4b Treat URLs for same file in nested archive and from jar root as equal
Consider the following two URLs:

jar:file:/test.jar!/BOOT-INF/classes!/foo.txt
jar:file:/test.jar!/BOOT-INF/classes/foo.txt

They both reference the same foo.txt file in the BOOT-INF/classes
directory of test.jar, however the first URL does so via the
nested BOOT-INF/classes archive. Previously, this difference in the
URLs would lead to PathMatchingResourcePatternResolver returning two
resources for foo.txt when asked to find all resources matching the
pattern classpath*:/**/*.txt.

This commit updates our Handler that is used for jar: URLs to consider
the two URLs above to be equivalent such that url1 is equal to url2
and the two urls will produce the same hash code.

Closes gh-7449
2016-11-23 14:04:45 +00:00
Johnny Lim
8038882d46 Polish
Closes gh-7403
2016-11-16 13:36:51 -08:00
Spring Buildmaster
e712a9ba8c Next Development Version 2016-11-08 16:55:37 +00:00
Andy Wilkinson
3a2d9e31ff Merge branch '1.4.x' into 1.5.x 2016-11-08 10:36:56 +00:00
Andy Wilkinson
808185ab4e Make LaunchedURLClassLoader Java 6 compatible again
Closes gh-7334
2016-11-08 10:35:18 +00:00
Andy Wilkinson
e576225959 Merge branch '1.4.x' into 1.5.x 2016-11-08 10:03:58 +00:00
dreis
7a797909ae Reinstate LaunchedURLClassLoader's registration as parallel capable
Closes gh-7334
2016-11-08 09:58:14 +00:00
Phillip Webb
5b66ffbb4b Merge branch '1.4.x' into 1.5.x 2016-10-31 23:09:36 -07:00
Andy Wilkinson
cdcc3d2f28 Ensure getResources("") includes nested root URLs
Previously, if Boot's JarURLConnection pointed to the root of a nested
entry, e.g. /BOOT-INF/classes, a call to getInputStream() would throw
an IOException. This behavior is reasonable for a URL that points
to the root of a normal jar as the jar itself is on the class path
anyway. However, for a nested jar it meant that a call to
ClassLoader.getResources("") would not include URLs for any nested
jars and directories (/BOOT-INF/classes and jars in /BOOT-INF/lib).
This is due to some logic in URLClassPath.Loader.findResource that
verifies a URL by opening a connection and calling getInputStream().

The result of missing URLs for the root of nested jars and directories
is that classpath scanning that scans from the root (not a good idea
for performance reasons, but something that we should support) would
not find entries in /BOOT-INF/classes or in jars in /BOOT-INF/lib.

This commit updates our JarURLConnection so that it no longer throws
an IOException when asked for an InputStream for the root of a nested
entry (directory or jar).

Fixes gh-7003
2016-10-31 12:06:35 -07:00
Andy Wilkinson
6b3eede59f Merge branch '1.4.x' into 1.5.x 2016-10-26 12:13:26 +01:00
Andy Wilkinson
6a68c8f7e0 Restore Handler logic that was changed during its merge
This commit restores the logic in Handler that was changed when
d20ac56a was merged, while leaving the structural improvements intact.

In addition to a couple of changes where a typo meant the wrong
variable was being referenced, some logic branches now return false
rather than called super. This realigns our Handler's behaviour with
that of the JDK's.

Some more tests have also been added to try to catch the problems that
were introduced during the merge.

Closes gh-7021
2016-10-26 11:10:38 +01:00
Phillip Webb
3c5328924c Merge branch '1.4.x' into 1.5.x 2016-10-25 20:17:55 -07:00
Andy Wilkinson
d20ac56afd Align our jar URL stream handler with the JDK's
Previously our handler didn't override parseURL or sameFile which
resulted in behaviour that differed from that of the JDK's handler.
Crucially, this would result in our JarURLConnection being passed
a spec that didn't contain a "!/". A knock-on effect of this was
that the connection would point to the root of the jar rather than
the intended entry.

Closes gh-7021
2016-10-25 20:16:32 -07:00
Andy Wilkinson
5b9eaab6c0 Merge branch '1.4.x' into 1.5.x 2016-10-24 22:16:23 +01:00
Andy Wilkinson
ee7141cf63 Allow PropertyLauncher loader.path to be configured using manifest
Closes gh-7178
2016-10-24 22:14:56 +01:00
Andy Wilkinson
9abafb839b Merge branch '1.4.x' into 1.5.x 2016-10-24 12:20:23 +01:00
Andy Wilkinson
be597d7ce9 Fix handling of cyrillic characters in AsciiBytes hashCode method
Closes gh-7202
2016-10-24 12:19:57 +01:00
Andy Wilkinson
b7c55fb192 Merge branch '1.4.x' into 1.5.x 2016-10-18 13:47:20 +01:00
Andy Wilkinson
a31180dd68 Avoid calling URL.getContent() when defining a package
URL.getContent() is shorthand for URL.openConnection().getContent().
It creates an InputStream that isn't explicitly closed. This means
that a file handle remains open until the URLConnection is garbage
collected. This can lead to the process exceeding the limit for open
files.

Previously, LaunchedURLClassLoader was using getConent() when
proactively defining a package for a class that is about to be loaded.
getContent() was used to access nested jar files to check if they
contained the package and, if so, to retrieve the jar's manifest.

In place of using getContent(), this commit uses JarURLConnection's
getJarFile() method which provides access to the JarFile without the
unwanted side-effect of opening an input stream.

Closes gh-7180
2016-10-18 13:35:33 +01:00
Stephane Nicoll
6bd670edbc Initiate 1.4.x branch 2016-09-21 11:11:24 +02:00
Spring Buildmaster
7e9ed5e1a7 Next Development Version 2016-09-21 07:58:07 +00:00
Spring Buildmaster
5f959b074f Next Development Version 2016-09-20 20:20:06 +00:00
Phillip Webb
56544c8dd5 Polish 2016-09-09 10:27:44 -07:00
Andy Wilkinson
7841af50ef Merge branch '1.3.x' 2016-08-31 13:56:04 +01:00
Andy Wilkinson
eb1c349f97 Polish “Avoid null handler package in JarFile protocol handler registration”
See gh-6759
2016-08-31 13:50:26 +01:00
hengyunabc
33a81e87d1 Avoid null handler package in JarFile protocol handler registration
Closes gh-6759
2016-08-31 13:44:41 +01:00
Phillip Webb
850141c405 Merge branch '1.3.x' 2016-08-29 15:30:30 +01:00
Phillip Webb
69e96c6211 Polish 2016-08-29 15:29:54 +01:00
Andy Wilkinson
984a6da262 Polising
Fix botched merge
2016-08-18 13:44:36 +01:00
Andy Wilkinson
e2ceece525 Merge branch '1.3.x' 2016-08-18 13:30:56 +01:00
Andy Wilkinson
85c0b44dcb Test that LaunchedURLClassLoader works when thread is interrupted
Previously, RandomAccessDataFile used a semaphore and acquired it
interruptibly. This meant that an interrupted thread was unable to
access the file. Notably, this would prevent LaunchedURLClassLoader from
loading classes or resources on an interrupted thread.

The previous commit (937f857) updates RandomAccessDataFile to acquire
the semaphore uninterruptibly. This commit adds a test to
LaunchedURLClassLoader to verify that it can now load a resource from
an interrupted thread.

Closes gh-6683
2016-08-18 12:03:05 +01:00
hengyunabc
937f85765c Ensure that LaunchedURLClassLoader works when thread is interrupted
See gh-6683
2016-08-18 11:59:45 +01:00
Spring Buildmaster
334baaeffd Next development version 2016-07-28 19:54:01 +00:00
Spring Buildmaster
a89ef5df6e Next Development Version 2016-07-28 09:18:40 +00:00