Commit Graph

276 Commits (15793b1abc9b999ae421e8942246574d4613c5d7)

Author SHA1 Message Date
Andy Wilkinson eb1c349f97 Polish “Avoid null handler package in JarFile protocol handler registration”
See gh-6759
8 years ago
hengyunabc 33a81e87d1 Avoid null handler package in JarFile protocol handler registration
Closes gh-6759
8 years ago
Phillip Webb 69e96c6211 Polish 8 years ago
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
8 years ago
hengyunabc 937f85765c Ensure that LaunchedURLClassLoader works when thread is interrupted
See gh-6683
8 years ago
Spring Buildmaster a89ef5df6e Next Development Version 8 years ago
Andy Wilkinson 4963cfd67b Reset thread's interrupted flag when catching InterruptedException
Closes gh-6360
8 years ago
Spring Buildmaster 2216369348 Next Development Version 8 years ago
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
9 years ago
Andy Wilkinson 159ef8f189 Ensure that URL returned from ExplodedArchive.getURL() is encoded
Closes gh-5971
9 years ago
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
9 years ago
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
9 years ago
Spring Buildmaster 819a9574a6 Next Development Version 9 years ago
Spring Buildmaster 376bbe68d8 Next Development Version 9 years ago
Phillip Webb af2483816b Fix JarFileTests to work on Windows
See gh-5287
9 years ago
Andy Wilkinson 74e27db486 Polish contribution 9 years ago
Vladimir Tsanev a0f76eab47 Update JarURLConnection to support jar:file://… URLs
Previously, JarURLConnection would fail when created with a URL that
began with jar:file:// as the double-slash is not included in jarFile.getUrl().getFile().

This commit updates JarURLConnection to normalise the value return from
url.getFile() to remove a double-slash when present.

Fixes gh-5287
Closes gh-5289
9 years ago
Spring Buildmaster 225d877ab9 Next Development Version 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 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
Andy Wilkinson 89beef4099 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 681a866cce Exclude Java agents from class loader created by PropertiesLauncher
PropertiesLauncher creates a ClassLoader that is used by the Launcher
to load an application’s classes. During the creation of this
ClassLoader URLs from its ClassLoader. This resulted resulting in Java
agents that are added to the system class loader via the -javaagent
launch option being available on both the system class loader and the
created class loader. Java agents are intended to always be loaded by
the system class loader. Making them available on another class loader
breaks this model.

This is the same problem that was in ExecutableArchiveLauncher and
that was fixed in ee08667e (see gh-863).

This commit updates PropertiesLauncher so that it skips the URLs of
any Java agents (found by examining the JVM’s input arguments) when
copying URLs over to the new ClassLoader, thereby ensuring that Java
agents are only ever loaded by the system class loader.

Closes gh-4911
9 years ago
Andy Wilkinson 27a81e1463 Complete static final logger changes that were started in ec2f33f9
This commit completes the changes to consistently used static final
fields for Log instances that were started in ec2f33f9. Specifically it:

 - Removes this. when accessing logger fields that are now static
 - Renames some fields from log to logger
 - Makes some logger fields static

See gh-4784
9 years ago
Phillip Webb 7397dbaf57 Allow ExitCodeGenerator to be used on Exceptions
Update exit code support to allow the ExitCodeGenerator interface to
be placed on an Exception. Any uncaught exception implementing the
interface and returning a non `0` status will now trigger a System.exit
with the code.

Fixes gh-4803
9 years ago
Andy Wilkinson 2aff82bb64 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 6117b6c5c8 Consistent use of tabs for indentation in pom files 9 years ago
Spring Buildmaster 8db59059a5 Next Development Version 9 years ago
Stephane Nicoll bb736e255b Fix SNAPSHOT version 9 years ago
Kirill Vlasov ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
9 years ago
Phillip Webb 2694605a4d Polish 9 years ago
Vladimir Tsanev 939b66f4ee Use fast exceptions in findResource(s)
Some libraries like aspectj are using findResource to see the raw
bytecode of a class. It will even call findResource for every method of
every class of beans that are post processed. This can be significant
performance hit on startup when LaunchedURLClassLoader and there are a
lot of nested jars.

See gh-3640
Fixes gh-4557
9 years ago
Vladimir Tsanev 1e2f133892 Use fast exceptions in findResource(s)
Some libraries like aspectj are using findResource to see the raw
bytecode of a class. It will even call findResource for every method of
every class of beans that are post processed. This can be significant
performance hit on startup when LaunchedURLClassLoader and there are a
lot of nested jars.

See gh-3640
Fixes gh-4557
9 years ago
Johnny Lim 8ec00c35bf Polish
Closes gh-4572
9 years ago
Spring Buildmaster 3f6f57a80e Next Development Version 9 years ago
Johnny Lim 0a85281a66 Fix typos
Closes gh-4463
9 years ago
Phillip Webb 6c2ea4648f Polish 9 years ago
Andy Wilkinson 17f61c1dad Update javadoc of LaunchedURLClassLoader to describe delegation model
Closes gh-3864
9 years ago
Phillip Webb 1e4d974ec0 Merge remote-tracking branch 'local12x/1.2.x' 9 years ago
Phillip Webb a79131f8d2 Organize imports with new settings
See gh-4234
9 years ago
Spring Buildmaster 2b38a861e3 Next Development Version 9 years ago
Andy Wilkinson 30f24eac0a Merge branch '1.2.x' 9 years ago
Andy Wilkinson 7e718cda26 Remove redundant hash from path of unpacked nested library
Closes gh-4124
9 years ago
Phillip Webb 04074fece1 Merge branch '1.2.x' 9 years ago
Phillip Webb 94736719f1 Reformat package-info.java files with Eclipse Mars 9 years ago
Andy Wilkinson 2afb641603 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 04c2bd9c89 Update tests to expect additional entry in test jar
Closes gh-4124
9 years ago
Andy Wilkinson 8948322d7a Merge branch '1.2.x' 9 years ago
Andy Wilkinson 888fa90265 Ensure that JarFileArchive unpacks entries to unique location
Previously, JarFileArchive would always unpack any entries marked for
unpacking to ${java.io.tmpdir}/spring-boot-libs. This could cause
problems if multiple Spring Boot applications were running on the same
host:

- If the apps are run as different users the first application would
  create the spring-boot-libs directory and the second and subsequent
  applications may not have write permissions to that directory
- Multiple apps may overwrite each others unpacked libs. At best this
  will mean one copy of a jar is overwritten with another identical
  copy. At worst the jars may have different contents so that some of
  the contents of the original jar disappear unexpectedly.

This commit updates JarFileArchive to use an application-specific
location when unpacking libs. A directory beneath ${java.io.tmpdir} is
still used but it's now named <jar-file-name>-spring-boot-libs-<uuid>.
A loop, limited to 1000 attempts, is used to avoid problems caused by
the uuid clashing.

Closes gh-4124
9 years ago