Commit Graph

669 Commits (46517cddd8d4632ac004d4a6141efc579078b78d)

Author SHA1 Message Date
Phillip Webb faba7a9514 Rename internal OutputCapture classes
Rename the internal versions of OutputCapture to prevent accidental
import.

See gh-5492
9 years ago
Andy Wilkinson c42f859390 Ensure that ExplodedArchive lists its file in a consistent order
Closes gh-5422
9 years ago
Andy Wilkinson c0b74119e0 Use manifest from class’s jar when defining its package
Previously, when defining a package for a class, LaunchedURLClassLoader
would use the manifest from the first location that contained the
required package. If the package was split across multiple locations,
this could lead to the manifest from a jar other than the one that
contains the class being used.

This commit updates LaunchedURLClassLoader so that it will use the
manifest of the jar file that contains the class which triggered the
definition of the package.

Closes gh-5485
9 years ago
Andy Wilkinson 1d099035b1 Protect against a race condition when defining packages
LaunchedURLClassLoader preemptively defines the package for any
classes that it attempts to load so that the manifest from a nested
jar is correctly associated with the package. This can lead to a race
where the package is defined on two threads in parallel, resulting
in an IllegalArgumentException being thrown.

This problem was manifesting itself as a NoClassDefFoundError.
If the initialization of a class failed due to the above-described
IllegalArgumentException, subsequent attempts to use that class
would then fail with a NoClassDefFoundError.

This commit updates LaunchedURLClassLoader to catch the
IllegalArgumentException and then double-check that the package has
already been defined. This approach, including thrown an
AssertionError when the second check fails, is modelled on the
approach taken by URLClassLoader.

Closes gh-5464
9 years ago
Andy Wilkinson 58ca9a1c5d Add a BuildInfo task for generating build.properties with Gradle
The commit adds a new BuildInfo task that can be used to generate
a build.properties file, intended for inclusion in the Actuator's
info endpoint.

A default instance of the task can be configure using the plugin's
DSL:

springBoot {
	buildInfo()
}

Additional properties can also be configured using the DSL:

springBoot {
	buildInfo {
		additionalProperties = [
			'foo': 'bar'
		]
	}
}

When configured via the DSL, the Java plugin's classes task is
configured to depend on the build info task. Alternatively, if more
control is required, the task can be declared and configured manually:

task buildInfo(type: org.springframework.boot.gradle.buildinfo.BuildInfo) {
	additionalProperties = [
		'foo': 'bar'
	]
}

classes {
	dependsOn buildInfo
}

See gh-2559
9 years ago
Phillip Webb 7942d9f787 Polish 9 years ago
Stephane Nicoll 10012cfddc Rename Maven plugin mojo
Rename the goal from `generate-build-info` to `build-info` for consistency.

See gh-2559
9 years ago
Stephane Nicoll dddea70985 Collect and display build information
This commit updates the Maven plugin to generate a
`META-INF/boot/build.properties` file with various build-specific
settings (group, artifact, name, version and build time). Additionally,
the plugin can be configured to write an arbitrary number of additional
properties.

A new `BuildProperties` bean is automatically exposed when such a file is
present. If that bean is present, an `InfoContributor` is automatically
created to expose that information under the `build` key.

As for the git contributor, it is possible to only display the core
settings or everything using the `management.info.build.mode` property.

See gh-2559
9 years ago
Andy Wilkinson 427d3140b3 Remove unwanted printing of stack trace from the Launcher
Previously, the Launcher would call ex.printStackTrace for any
exception that was thrown when launching the application. This was
unnecessary as the stack trace should already have been logged by
the application when it failed to start.

This commit removes the call to ex.printStackTrace, thereby allowing
an exception to be logged only once or not at all after successful
failure analysis.

Closes gh-5358
9 years ago
Phillip Webb 644ae2c21a Merge branch '1.3.x' 9 years ago
Phillip Webb 5e722dae6a Polish 9 years ago
Stephane Nicoll cc2f6f4b9c Merge branch '1.3.x' 9 years ago
Stephane Nicoll a83dae0e10 Polish contribution
Closes gh-5335
9 years ago
Eric Bottard 79cd01eb7a Fix configuration property name when group is empty
See gh-5335
9 years ago
Phillip Webb 73cbb2f40a Polish 9 years ago
Stephane Nicoll c6c001457a Fix description of classifier attribute
See gh-5258
9 years ago
Stephane Nicoll 7f3ee2e405 Disable attach of repackaged artifact
This commit allows to generate the packaged artifact only locally by
adding a new `attach` property. If `attach` is set to `false` explicitly,
only the main artifact is installed/deployed.

Closes gh-5258
9 years ago
Andy Wilkinson ad7cf48497 Update Repackager to use Java 8 APIs safely
Previously, Repackager used Java 8 APIs without protecting against the
possibility of a NoSuchMethodError on earlier versions of Java.
This commit wraps the Java 8 APIs in try-catch blocks to ensure
that they do not cause a failure on Java versions before 8, while
still making full use of Java 8's capabilities when available.

Closes gh-5280
9 years ago
Andy Wilkinson 779649bfdb Merge branch '1.3.x' 9 years ago
Andy Wilkinson bb473c32e2 Enable Animal Sniffer checking of spring-boot-loader-tools
Previously, Animal Sniffer checking of spring-boot-loader-tools
was disabled as it failed with an NPE. This has been fixed in
Animal Sniffer 1.15.

This commit upgrades Animal Sniffer to 1.15 and adds the necessary
annotations to suppress failures for safe usage of sun.* and Java 7
APIs.

Note that UsesUnsafeJava has been copied from spring-boot and made
package-private. This retains the clearer intent of the custom
annotation (versus @IgnoreJRERequirement) while avoiding the change
in the build order that would be necessary for
spring-boot-loader-tools to use the annotation from spring-boot.

Closes gh-5284
9 years ago
Uwe Schaefer 9c3003071b Add CONF_FOLDER property
Closes gh-5203
9 years ago
Spring Buildmaster 225d877ab9 Next Development Version 9 years ago
Andy Wilkinson af32d6e8ee Allow LOG_FOLDER and PID_FOLDER defaults to be set at build time
This commit enhances the default launch script to allow the default
values for LOG_FOLDER and PID_FOLDER to be set at build time. They
can now be set using the logFolder and pidFolder properties
respectively.

Closes gh-4787
9 years ago
Andy Wilkinson 44ddfcc7fa Upgrade copyright headers of all files changed in 2016 9 years ago
Andy Wilkinson d9382244d8 Handle mixture of encoded and unencoded chars in JarURLConnection
Previously, JarURLConnection would corrupt a URL that contained a
mixture of encoded and unencoded double-byte characters. URLs that
only contained unencoded double-byte characters were not affected as
they are passed through as-is.

This commit updates JarURLConnection.JarEntryName to correctly handle
characters with a value that won't fit in a single signed byte (a
value greater than 127). Such characters are now URL encoded and then
written to the output stream as multiple bytes.

Closes gh-5194
9 years ago
Phillip Webb 89b7704977 Extract spring-boot-test.jar
Relocate the `org.springframework.boot.test` package from the
`spring-boot.jar` to `spring-boot-test.jar`.

Fixes gh-5184
9 years ago
Phillip Webb 4b55144d80 Polish 9 years ago
Andy Wilkinson 5ed4ef1272 Add manifest entries for location of lib and classes in executable archives
Closes gh-5183
9 years ago
Andy Wilkinson fcbf15aea3 Update Ant support following changes the executable jar layout
Closes gh-4897
9 years ago
Andy Wilkinson 87fe0b2ade Use a conventional delegation model in LaunchedURLClassLoader
When an application is run as an executable archive with nested jars,
the application's own classes need to be able to load classes from
within the nested jars. This means that the application's classes need
to be loaded by the same class loader as is used for the nested jars.
When an application is launched with java -jar the contents of the
jar are on the class path of the app class loader, which is the
parent of the LaunchedURLClassLoader that is used to load classes
from within the nested jars. If the root of the jar includes the
application's classes, they would be loaded by the app class loader
and, therefore, would not be able to load classes from within the
nested jars.

Previously, this problem was resolved by LaunchedURLClassLoader being
created with a copy of all of the app class laoder's URLs and by
using an unconventional delegation model that caused it to skip its
parent (the app class loader) and jump straight to its root class
loader. This ensured that the LaunchedURLClassLoader would load both
the application's own classes and those from within any nested jars.
Unfortunately, this unusual delegation model has proved to be
problematic. We have seen and worked around some problems with Java
Agents (see gh-4911 and gh-863), but there are others (see gh-4868)
that cannot be made to work with the current delegation model.

This commit reworks LaunchedURLClassLoader to use a conventional
delegate model with the app class loader as its parent. With this
change in place, the application's own classes need to be hidden
from the app class loader via some other means. This is now achieved
by packaging application classes in BOOT-INF/classes (and, for
symmetry, nested jars are now packaged in BOOT-INF/lib). Both the
JarLauncher and the PropertiesLauncher (which supports the executable
jar layout) have been updated to look for classes and nested jars in
these new locations.

Closes gh-4897
Fixes gh-4868
9 years ago
Stephane Nicoll b60e9e5cb9 Expose hints for Maps
This commit fixes the json parser so that hints for maps is also made
available.

Closes gh-5152
9 years ago
Phillip Webb 00cfe1d054 Use AssertJ in spring-boot-tools
See gh-5083
9 years ago
Phillip Webb 516afcd2ca Polish 9 years ago
Andy Wilkinson 9dbef5d9b0 Remove use a separate runner thread from the Launcher
Previously, the Launcher was creating a new runner thread that would
call the application's main method. An exception thrown by this thread
is handled differently to one thrown by the JVM's main thread leading
to different exit behaviour. Furthermore, the separate thread isn't
actually necessary.

This commit removew the use of a separate runner thread from the
Launcher. This means that the JVM's exit behaviour will be consistent
and also removes the overhead of createing a starting an extra thread.

Closes gh-5006
9 years ago
Johnny Lim 46540de694 Fix typos
Closes gh-5067
9 years ago
Phillip Webb acbb4e63f2 Clear caches on ApplicationContext load
Ensure that JarFile caches are cleared once the ApplicationContext has
loaded. Caches are cleared manually with the assumption that no
further class loading is likely.

Closes gh-4882
9 years ago
Phillip Webb e2368b909b Reduce memory consumption of fat/exploded jars
Refactor `spring-boot-loader` to reduce the amount of memory required
to load fat & exploded jars. Jar files now no longer store a full list
of entry data records, but instead use an array of entry name hashes.

Since ClassLoaders often ask each JAR if they contain a particular
entry (and mostly they do not), the hash array provides a quick way to
deal with misses. Only when a hash does exist is data actually loaded
from the underlying file.

In addition to the JarFile changes, the Archive abstraction has also
been updated to reduce memory consumption.

See gh-4882
9 years ago
Phillip Webb 858a854ce1 Drop use of loggers in Launchers
Remove the use of JDK loggers in Launcher and PropertiesLauncher to
ensure allow the custom Log4j2 `LogManager` to be used with Spring Boot
applications.

Fixes gh-3815
9 years ago
Stephane Nicoll 11d8515594 Add failsafe default configuration
Provides better default for integration tests. Also expand the
documentation of the maven plugin in that area.

Closes gh-4223
9 years ago
Stephane Nicoll bead239448 Remove support for Log4j
Apache Log4j 1.x is EOL and has now been replaced by log4j 2. This commit
removes the deprecated support for Log4j 1.x

See gh-4905
9 years ago
Phillip Webb fbaf209240 Move master to 1.4.0.BUILD-SNAPSHOT 9 years ago
Spring Buildmaster 504d3e97ba Next development version 9 years ago
Phillip Webb 93c3b22bb4 Merge branch '1.2.x' 9 years ago
Phillip Webb c71aa32fbb Polish 9 years ago
Andy Wilkinson 9dc858cdf5 Add missing properties to RepackageTask and improve test coverage
Closes gh-4978
9 years ago
Andy Wilkinson 854cacdb4f Fix useStartStopDaemon in launch script and allow config via conf file
Commit 5a1ee6eb added support for disabling use of start-stop-daemon
via a placeholder in the default launch script. Unfortunately, that
placeholder was subsequently broken in 81a47639.

This commit reinstates the placeholder and adds tests to verify that all
of the placeholders in the launch script can be replaced and that they
have the required default values. Furthermore, it also allows the use of
start-stop-daemon to be configured via USE_START_STOP_DAEMON in an
app’s .conf file. This allows the configuration to be changed after the
app has been built.

Closes gh-4985
9 years ago
Andy Wilkinson 2dc3660a32 Align launcher exception handling with direct invocation of main method
Previously, if an application’s main method threw an exception,
MainMethodRunner would catch the exception and call System.exit(1).
This meant that the JVM would exit, irrespective of whether or not
any non-daemon threads were running. In contrast, when an application’s
main method was invoked directly (in an IDE, for example) the JVM
would not exit if one or more non-daemon threads were running. This
is standard JVM behaviour that we should be consistent with in the
launcher.

This commit updates MainMethodRunner to wrap any exception thrown by an
application’s main method in a RuntimeException and rethrow it. This
alllows the JVM to handle the exception and use its normal rules for
deciding whether or not it should exit.

Closes gh-4984
9 years ago
Stephane Nicoll 7842f50e30 Add property to skip integration tests
Generalize the `skip` property to start and stop goals so that one
can control if the Spring Boot app is starting via a configuration
property.

Note that this only controls the Spring Boot Maven plugin and the
failsafe maven plugin should be updated accordingly.

Closes gh-4922
9 years ago
Andy Wilkinson 93ef795159 More use entrySet() rather than using keySet() and get(key)
This commit replaces some more occurrances of keySet() and get(key)
with more efficient usage of the map's entry set.

See gh-4813
9 years ago
Andy Wilkinson 89beef4099 Merge branch '1.2.x' 9 years ago