Commit Graph

440 Commits

Author SHA1 Message Date
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
Andy Wilkinson 31b0e81765 Add @FunctionalInterface to remaining public and protected interfaces
See gh-6857
2017-01-27 16:41:09 +00:00
Eddú Meléndez 3d52c86a21 Annotate interfaces with @FunctionaInterface
Closes gh-6857
2017-01-27 16:41:01 +00:00
Spring Buildmaster ed1ce140c0 Next Development Version 2017-01-26 14:20:39 +00:00
Stephane Nicoll 661fd848eb Merge branch '1.5.x' 2017-01-25 11:02:32 +01: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
Andy Wilkinson 2b75570680 Fix dead code warning in CentralDirectoryParserTests 2017-01-24 11:07:43 +00:00
Phillip Webb f92f019418 Don't mock package private class
See gh-7770
2017-01-05 14:39:22 -08:00
Phillip Webb 77f9bb09ca Further Polish Mockito 2 support
See gh-7770
2017-01-05 14:29:29 -08:00
Phillip Webb f8c7890a45 Merge branch '1.5.x' 2017-01-03 15:36:47 -08: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 53f1df86a2 Merge branch '1.5.x' 2016-12-30 12:17:28 -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
Phillip Webb 6e02fe59f7 Merge branch '1.5.x' 2016-12-21 22:32:43 -08:00
Johnny Lim e12b4a944f Polish 2016-12-21 20:18:04 -08:00
Phillip Webb 1f417997f3 Merge branch '1.5.x' 2016-12-19 13:21:18 -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 6eaa8d7c56 Merge branch '1.5.x' 2016-12-08 11:38:23 +00: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
Stephane Nicoll bd2415463c Merge branch '1.5.x' 2016-12-01 12:13:02 +01:00
Oscar Utbult 3a7969b8bb Remove redundant StringBuilder
Closes gh-7538
2016-12-01 12:11:04 +01:00
Stephane Nicoll e7275b62dc Merge branch '1.5.x' 2016-11-30 08:27:30 +01:00
Oscar Utbult fabe35fdc4 Remove redundant toString() invocation
Closes gh-7527
2016-11-30 08:23:03 +01:00
Stephane Nicoll 9c374e7755 Merge branch '1.5.x' 2016-11-29 08:03:08 +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 b4c3f4f504 Merge branch '1.5.x' 2016-11-28 15:37:43 -08: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 c714880001 Merge branch '1.5.x' 2016-11-23 14:05:10 +00: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
Phillip Webb cb7c0b5031 Merge branch '1.5.x' 2016-11-16 16:06:53 -08: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 78fcb311c9 Merge branch '1.5.x' 2016-11-08 10:04:09 +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 98a3ae9ac4 Merge branch '1.5.x' 2016-10-31 23:13:37 -07: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 f2c7e22731 Merge branch '1.5.x' 2016-10-26 12:13:38 +01: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 57fb3888ac Merge branch '1.5.x' 2016-10-25 20:18:47 -07: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 f0798253a3 Merge branch '1.5.x' 2016-10-24 22:16:34 +01: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 3f655d998d Merge branch '1.5.x' 2016-10-24 12:20:41 +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 2a685a8c15 Merge branch '1.5.x' 2016-10-18 13:47:33 +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 6643ec3713 Next development version 2016-09-21 17:05:50 +02: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
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
Andy Wilkinson 8e669e2eef Merge branch '1.3.x 2016-07-11 17:03:16 +01:00
Andy Wilkinson 4963cfd67b Reset thread's interrupted flag when catching InterruptedException
Closes gh-6360
2016-07-11 16:46:05 +01:00
Spring Buildmaster 2216369348 Next Development Version 2016-07-04 14:15:02 +00:00
Phillip Webb a5cddf79a8 Reduce JarURLConnection allocations
Update JarURLConnection & Handler so that a shared static final
connection is returned for entries that cannot be found.

See gh-6215
2016-06-26 08:40:25 -07:00
Phillip Webb c22a0e90a2 Polish 2016-06-24 11:52:43 -07:00
Andy Wilkinson 0d207d438a Improve the performance of JarURLConnection
This commit improves the performance of JarURLConnection. There are two
main changes:

Firstly, the way in which the spec is determined has been changed so
that it’s no longer necessary to create an absolute file. Instead,
the JarFile’s pathFromRoot is used to extract the spec from the URL
relative to the JarFile.

Secondly, the number of temporary Objects that are created has been
reduced, for example by tracking an index as we process a String
rather than creating a new substring for each iteration.

See gh-6215
2016-06-24 16:14:33 +01:00
Andy Wilkinson 9788a7bdda Merge branch '1.3.x' 2016-06-24 11:53:01 +01:00
Andy Wilkinson 8d491f278b Create FilePermission lazily in JarURLConnection
JarURLConnection is very performance sensitive. The change in 3772d9f
meant that every JarURLConnection would create a FilePermission,
irrespective of whether it was actually used.

This commit updates JarURLConnection to create its FilePermission
lazily. When there is no security manager a permission will no longer
be created at all.

Closes gh-5411
See gh-6215
2016-06-24 11:49:35 +01:00
Phillip Webb bdb0eb29a3 Cache JarURLConnection absoluteFile lookups
Update JarURLConnection.getNormalizedFileUrl so that expensive absolute
file lookups are cached.

See gh-6177
See gh-6109
2016-06-23 14:30:10 -07:00
Andy Wilkinson a395679b95 Fix JarURLConnectionTests on Windows
Closes gh-6109
2016-06-22 10:02:42 +01:00
Andy Wilkinson 02dbd6e4a7 Allow JarURLConnection to be created with a relative URL
Previously, JarURLConnection assumed that that URL with which it was
created would contain the absolute path of the underlying jar file.
This meant that when it was created with a relative URL, it could fail
to find an entry or throw a StringIndexOutOfBoundsException.

This commit updates the logic for normalizing the input URL so that
both absolute and relative URLs are supported.

Closes gh-6109
2016-06-21 11:30:51 +01:00
Andy Wilkinson af20dc6cc4 Merge branch '1.3.x' 2016-06-15 20:52:18 +01:00
Andy Wilkinson 159ef8f189 Ensure that URL returned from ExplodedArchive.getURL() is encoded
Closes gh-5971
2016-06-15 20:47:29 +01:00
Phillip Webb 77f6b4c983 Formatting 2016-06-09 20:45:37 -07:00
Andy Wilkinson 436b58acbf Merge branch '1.3.x' 2016-06-01 15:41:36 +01:00
Andy Wilkinson 3772d9f937 Update JarURLConnection to only require file read permission
Previously, JarURLConnection didn't override getPermission(). This
meant that it required all permissions. This was at odds with the
Oracle JVM's concrete sun.net.www.protocol.jar.JarURLConnection which
overrides getPermission to return a FilePermission with the read
action for the path of the underlying jar.

This commit updates our JarURLConnection to align its behaviour with
sun.net.www.protocol.jar.JarURLConnection.

Closes gh-5411
2016-06-01 15:33:36 +01:00
Andy Wilkinson e561cc1997 Don't use a separate thread in the launcher to call app's main method
Using a separate thread to call the application's main method is
unnecessary – the context class loader of the current thread can be
updated instead – and makes exception and exit code handling more
complicated than it needs to be.

This commit updates the Launcher so that it calls the main method
runner using the current (main) thread. As a result, any exception
that's thrown will be caught by the JVM and result in a non-zero exit
code being returned from the process.

Closes gh-5922
2016-05-12 16:57:16 +01:00
Spring Buildmaster 819a9574a6 Next Development Version 2016-05-10 05:28:34 +00:00