381 Commits

Author SHA1 Message Date
Phillip Webb
3107d2de51 Merge branch '2.3.x'
Fixes gh-21705 in master
2020-06-05 15:33:46 -07:00
Phillip Webb
9a235197dc Propagate manifest to exploded jars
Update `LaunchedURLClassLoader` so that packages defined from exploded
archive folders have manifest attributes applied to them. Prior to this
calling `package.getImplementationTitle()` would only return the a
manifiest attribute when running non-exploded.

The root cause of this issue is the way that `URLClassLoader` handles
the different URL types. For URLs that reference a jar the manifest is
available. For URLs that reference a folder it isn't. When running
exploded we use a URL that references to the `BOOT-INF/classes` folder
directly. To fix the issue we now attempt to detect when `definePackage`
is being called directly, and replace `null` entries with actual
manifest values.

Fixes gh-21705
2020-06-05 15:28:16 -07:00
dreis2211
54f93e9b0f Fix multi-release JAR test on JDK 15
See gh-21605
2020-06-05 11:56:50 +02:00
Madhura Bhave
2dc8048d08 Add missing since tags
Closes gh-21576
2020-06-02 17:22:46 -07:00
Phillip Webb
038ae93406 Update copyright year of changed files 2020-05-13 16:48:51 -07:00
Johnny Lim
665a127448 Fix JarFileTests.getInputStreamWhenClosed()
See gh-21365
2020-05-08 16:06:42 +02:00
Phillip Webb
4a8492d428 Further optimize StringSequence.startsWith
See gh-21259
2020-05-05 18:37:10 -07:00
dreis2211
70ffc70993 Optimize StringSequence.startsWith
See gh-21259
2020-05-05 18:37:10 -07:00
Phillip Webb
ad1248e4ec Replace "folder" with "directory"
Consistently use the term "directory" instead of "folder"

Closes gh-21218
2020-04-28 19:20:24 -07:00
Phillip Webb
50e9674631 Backport "Attempt to prevent JarFiles from being left open"
Update `JarFile` so that `super.close()` is called early so that the
file is not left open. Since we re-implement `JarFile` methods to work
directly on the underlying `RandomAccessDataFile`, it should be safe
to close immediately.

Closes gh-21177
2020-04-27 19:03:52 -07:00
Phillip Webb
77b9dd900c Merge branch '2.2.x'
See gh-21127
2020-04-25 22:21:23 -07:00
Phillip Webb
7d53f7d27f Attempt to prevent JarFiles from being left open
Update `JarFile` to also call `super.close()` early for nested jars.

See gh-21126
2020-04-25 22:20:53 -07:00
Phillip Webb
4f47b7b46a Merge branch '2.2.x'
See gh-21127
2020-04-25 13:32:43 -07:00
Phillip Webb
7c6e912463 Attempt to prevent JarFiles from being left open
Update `JarFile` so that `super.close()` is called early so that the
file is not left open. Since we re-implement `JarFile` methods to work
directly on the underlying `RandomAccessDataFile`, it should be safe
to close immediately.

See gh-21126
2020-04-25 13:03:07 -07:00
dreis2211
848127ae49 Avoid recompiling pattern in Handler#canonicalize
See gh-21103
2020-04-25 09:02:21 +02:00
dreis2211
5eb5bf0a2d Polish
See gh-21009
2020-04-25 08:54:47 +02:00
Johnny Lim
29717423a3 Remove this keyword on member method invocations
See gh-21007
2020-04-25 08:49:44 +02:00
Phillip Webb
ed7a5db174 Fail operations when JarFile is closed
Update `JarFile` to track when the instance has been closed and throw
an exception in the same way that `ZipFile` does.

Closes gh-21072
2020-04-21 18:12:03 -07:00
Phillip Webb
cc33e23d31 Merge branch '2.2.x'
Closes gh-21074
2020-04-21 17:22:11 -07:00
Phillip Webb
6bf933205c Merge branch '2.1.x' into 2.2.x
Fixes gh-21073
2020-04-21 17:21:32 -07:00
Phillip Webb
c85918b8b3 Create new JarFile instance for URL connections
Update `JarURLConnection` to ensure that when connections are opened
a new copy of the JarFile is provided.

Prior to this commit, a single `JarFile` instance was shared which meant
that it could be accidental closed if accessed via
`JarURLConnection.getJarFile()`. If the underlying jar file is closed
then it's possible for a `NoClassDefFoundError` to be thrown if running
on JDK 11 with an active `SecurityManager`.

Closes gh-17796
2020-04-21 16:32:51 -07:00
Stephane Nicoll
4648ecef6e Merge branch '2.2.x'
Closes gh-20969
2020-04-15 09:48:32 +02:00
Stephane Nicoll
1dd8dcc6c9 Polish "Polish JarFile to extra anonymous inner class"
See gh-20882
2020-04-15 09:39:00 +02:00
Konrado85
e0d1cf0e38 Polish JarFile to extra anonymous inner class
See gh-20882
2020-04-15 09:33:24 +02:00
Konrado85
9f4c39c985 Change PropertiesLauncher equals method to use URI
See gh-20872
2020-04-13 13:55:17 +02:00
Phillip Webb
1640add8be Don't use Assert class from loader
Remove the use of `Assert` since it's unavailable that early.
2020-04-07 12:09:43 -07:00
Phillip Webb
df58b9baa2 Use YAML compatible classpath.idx format
Update the `classpath.idx` format to align with `layers.idx` and allow
third-parties can parse it as YAML

Closes gh-20861
2020-04-06 19:18:22 -07:00
Oleg Zhurakousky
9f75f30856 Change call to createClassLoader(URL) from 'super' to 'this'
ExecutableArchiveLauncher.createClassLoader(Iterator) calls
createClassLoader(URL) method with 'super'. This means overriding
createClassLoader(URL) is not possible without also overriding
createClassLoader(Iterator). The switch to 'this' enables that.

See gh-20851
2020-04-06 10:40:37 -07:00
Madhura Bhave
4e3cdf936f Support flat jar layering with Maven
Update the Maven plugin so that layered jars now use the regular "flat"
format. The layers.idx file now describes which layer each file should
be placed.

See gh-20813

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-04-03 00:34:27 -07:00
Madhura Bhave
ad164269e9 Update classpath index to use jar name instead of full path
See gh-20564
2020-03-25 10:46:59 -07:00
Phillip Webb
9a33a723fe Update copyright year of changed files 2020-03-23 14:15:08 -07:00
Stephane Nicoll
579a6ac254 Adapt tests for support for Java 14
See gh-20576
2020-03-19 14:54:33 +01:00
Madhura Bhave
3e8ee2a296 Add missing package-info.json
Closes gh-20516
2020-03-16 16:11:02 -07:00
dreis2211
53e8e49552 Fix JarFileTests for multi-release JARs on JDK14
See gh-20180
2020-03-07 16:55:02 +01:00
dreis2211
4f824bf9ad Fix duplicate words
See gh-20210
2020-02-18 13:34:56 +01:00
zhangt2333
e2d87a89d0 Polish
See gh-20192
2020-02-16 17:19:18 +01:00
Madhura Bhave
bceed1305f Jar files added after build time should be added to classpath
Fixes gh-19973
2020-01-30 15:38:49 -08:00
dreis2211
d8e2349e47 Use Supplier variants of Assert
See gh-19864
2020-01-28 15:04:11 +01:00
Stephane Nicoll
e044817fe7 Migrate remaining use of ClassLoader.loadClass to Class.forName
Closes gh-19824
2020-01-23 13:15:45 +01:00
Phillip Webb
2b83edeb27 Fix jarmode support in unexploded jars
Update `LaunchedURLClassLoader` to ensure that the `JarModeLauncher`
is created in the correct classloader.

Prior to this commit the launcher was created by the application
classloader and did not have access to any of the required
`org.springframework` classes.

See gh-19848
2020-01-22 23:07:18 -08:00
Phillip Webb
77bbe089b2 Update copyright year of changed files 2020-01-22 20:24:23 -08:00
Phillip Webb
e0013454b5 Use parentheses when declaring dependencies
Update all dependencies declarations to use the form `scope(reference)`
rather than `scope reference`.

Prior to this commit we declared dependencies without parentheses unless
we were forced to add them due to an `exclude`.
2020-01-22 16:02:38 -08:00
Phillip Webb
0209cd3e4c Polish quote form used in Gradle scripts
Replace Gradle single quote strings with the double quote form
whenever possible. The change helps to being consistency to the
dependencies section where mostly single quotes were used, but
occasionally double quotes were required due to `${}` references.
2020-01-22 15:49:52 -08:00
Phillip Webb
951d0b0fdf Fix exploded jar classloader issues
Fix a bug in `ExplodedURLClassLoader` and merge the code into the
existing `LaunchedURLClassLoader` class. Also polish a few method
names relating to layer support.

See gh-19848
See gh-19767
2020-01-22 12:56:14 -08:00
Phillip Webb
73a42050d6 Add jarmode support to the loader code
Update the `Launcher` class to allow a packaged jar to be  launched in
a different mode. The launcher now checks for a `jarmode` property and
attempts to find a `JarMode` implementation using the standard
`spring.factories` mechanism.

Closes gh-19848
2020-01-22 01:23:11 -08:00
Madhura Bhave
e9d61bac75 Support generation and loading of layered jars
Support an alternative fat jar format that is more amenable to Docker
image layers.

The new format arranges files in the following structure:

	BOOT-INF/
	  layers/
	    <layer-name #1>
	      /classes
	      /lib
	    <layer-name #2>
	      /classes
	      /lib

The `BOOT-INF/layers.idx` file provides the names of the layers and the
order in which they should be added (starting with the least changed).

The `JarLauncher` class can load layered jars in both fat and exploded
forms.

Closes gh-19767

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-01-15 23:32:58 -08:00
Madhura Bhave
45b1ab46c3 Add classpath index support for exploded archives
Update the `Repackager` class so that an additional `classpath.idx` file
is written into the jar that provides the original order of the
classpath. The `JarLauncher` class now uses this file when running as
an exploded archive to ensure that the classpath order is the same as
when running from the far jar.

Closes gh-9128

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-01-15 23:31:17 -08:00
Phillip Webb
ad72f86bdb Polish loader and loader-tools
Polish and refactor `spring-boot-loader` and `spring-boot-loader-tools`
to make it easier to add indexing and layering support.

Closes gh-19766
2020-01-15 23:29:11 -08:00
Andy Wilkinson
56e30258fb Merge branch '2.2.x' 2020-01-15 20:45:42 +00:00
Andy Wilkinson
b7e250eb04 Merge branch '2.1.x' into 2.2.x 2020-01-15 20:45:24 +00:00