Commit Graph

204 Commits

Author SHA1 Message Date
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Sebastien Deleuze 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
Juergen Hoeller e835f4d025 Revised png and jpeg mappings
Issue: SPR-15546
Issue: SPR-15557
2017-05-17 14:21:44 +02:00
Stephane Nicoll 547c4f69a4 Add getTargetDataSource to TransactionAwareCacheDecorator
Issue: SPR-15479
2017-04-27 11:34:10 +02:00
Stephane Nicoll 333e5c6b01 Polish 2017-04-27 11:29:14 +02:00
Juergen Hoeller a55a0f26cb FreeMarkerConfigurationFactory falls back to SpringTemplateLoader on any exception
Issue: SPR-15445
2017-04-12 18:06:37 +02:00
Stephane Nicoll 73909f41cb Polish 2017-02-20 16:29:05 +01:00
Stephane Nicoll 1c74a1a0fe Improve allowNullValue handling when a null value is provided
This commit improves `AbstractValueAdaptingCache` to throw a dedicated
exception if `allowNullValues` is `false` and a `null` value is provided
anyway. This avoid a lower-level exception from the cache library that
will miss some context.

Issue: SPR-15173
2017-02-20 16:08:08 +01:00
Juergen Hoeller 214d0d76a5 Polishing 2017-02-18 01:01:35 +01:00
Stephane Nicoll 85b20aa08a Polish 2017-02-06 15:27:38 +01:00
Stephane Nicoll 908261b136 Polish contribution
Closes gh-1292
Issue: SPR-15188
2017-02-06 15:27:38 +01:00
David Brimley 3476d10efa Honour ErrorHandler if `Cache.put` fails
This commit makes sure that the `ErrorHandler` is invoked if the cache
fails to put an element (be it in the main cache or the exception cache).

See gh-1292
Issue: SPR-15188
2017-02-06 15:27:38 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Juergen Hoeller e19dff179e Polishing 2017-01-12 21:18:01 +01:00
Juergen Hoeller 3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
wolverine.kim a3062dfe78 Fix typo
Closes gh-1129
2016-08-10 10:44:07 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Juergen Hoeller 88fcd0a2ed Framework build compatible with JDK 9 (tests running against java.base module)
Issue: SPR-13344
2016-07-19 19:37:34 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Sam Brannen 22345f7c25 Upgrade tests to EhCache 2.10+
Issue: SPR-13794
2016-07-11 17:17:03 +02:00
Juergen Hoeller e8b5374d87 Require EhCache 2.10+
Issue: SPR-13794
2016-07-08 16:28:24 +02:00
Stephane Nicoll 2bf9bc312e Remove Guava cache support
This commit removes `GuavaCache` and support classes. Caffeine supersedes
the caching support in the Google Guava library with an actively maintained
Java 8+ version in standalone form.

As it is the only Guava feature Spring framework integrates with, this
commit removes effectively any reference to Guava.

Issue: SPR-13797
2016-07-08 10:57:05 +02:00
Juergen Hoeller a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00
Stephane Nicoll e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Juergen Hoeller 7dda9fbd8c Drop JasperReports support
Issue: SPR-13294
2016-07-05 23:06:15 +02:00
Juergen Hoeller bc2c22d51e Streamline XML namespace support towards unversioned schemas
This commit also removes support code for outdated options which were only available in older schema versions.

Issue: SPR-13499
2016-07-05 20:50:03 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller ff6ead1fff Remove Velocity support
Issue: SPR-13795
2016-07-04 23:30:58 +02:00
Juergen Hoeller 81057a2cee Require EhCache 2.10+
Issue: SPR-13794
2016-07-04 23:22:32 +02:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Juergen Hoeller 4ae065996b Polishing
(cherry picked from commit aa5c12c)
2016-04-08 23:06:25 +02:00
Juergen Hoeller 157dcab56c Cleanup of remaining direct BeanWrapper usage
Issue: SPR-14121
2016-04-07 14:27:22 +02:00
Juergen Hoeller 6db6f23a04 Quartz ResourceLoaderClassLoadHelper explicitly falls back to classpath lookup
Issue: SPR-13706
2016-04-05 12:18:48 +02:00
Juergen Hoeller 8bfba6a07a EhCacheManagerFactoryBean logs cache manager name
Issue: SPR-14110
2016-04-04 14:56:08 +02:00
Juergen Hoeller 14bf6509ec Consistent cache key implementation across transaction and cache attribute sources
Includes consistent applicability of class-level metadata to user-level methods only.

Issue: SPR-14017
Issue: SPR-14095
2016-03-30 14:13:04 +02:00
Juergen Hoeller a68b910b7c TimerScheduledFuture correctly calculates getDelay result
Issue: SPR-13977
2016-02-24 17:11:36 +01:00
Juergen Hoeller 25be5e060c TaskDecorator callback supported by common TaskExecutor implementations
Issue: SPR-13930
2016-02-17 16:58:02 +01:00
Stephane Nicoll aed56ea732 Upgrade to Caffeine 2.1.0 2016-01-28 16:50:29 +01:00
Stephane Nicoll 29700658d4 Support Quartz trigger without JobDetail
This commit allows to create a Quartz trigger implementation via
either `CronTriggerFactoryBean` or `SimpleTriggerFactoryBean` even if no
job detail is provided.

Issue: SPR-13604
2016-01-19 18:03:03 +01:00
Juergen Hoeller 773d175681 Polishing 2016-01-13 12:52:05 +01:00
Stephane Nicoll 7d0ebddebe Flag Caffeine as Java8+ only
See also SPR-13824
2015-12-28 15:06:35 +01:00
Stephane Nicoll 19d97c4253 Support for multi-threaded cache access
Previously, if a `@Cacheable` method was accessed with the same key by
multiple threads, the underlying method was invoked several times instead
of blocking the threads while the value is computed. This scenario
typically affects users that enable caching to avoid calling a costly
method too often. When said method can be invoked by an arbitrary number
of clients on startup, caching has close to no effect.

This commit adds a new method on `Cache` that implements the read-through
pattern:

```
<T> T get(Object key, Callable<T> valueLoader);
```

If an entry for a given key is not found, the specified `Callable` is
invoked to "load" the value and cache it before returning it to the
caller. Because the entire operation is managed by the underlying cache
provider, it is much more easier to guarantee that the loader (e.g. the
annotated method) will be called only once in case of concurrent access.

A new `sync` attribute to the `@Cacheable` annotation has been addded.
When this flag is enabled, the caching abstraction invokes the new
`Cache` method define above. This new mode bring a set of limitations:

* It can't be combined with other cache operations
* Only one `@Cacheable` operation can be specified
* Only one cache is allowed
* `condition` and `unless` attribute are not supported

The rationale behind those limitations is that the underlying Cache is
taking care of the actual caching operation so we can't really apply
any SpEL or multiple caches handling there.

Issue: SPR-9254
2015-12-21 13:34:35 +01:00
Stephane Nicoll 3a238a2b61 Polish contribution
Closes gh-921

Issue: SPR-13690
2015-12-18 15:47:13 +01:00
Ben Manes 13aabeef37 Add caching support for Caffeine
Issue: SPR-13690
2015-12-18 15:47:13 +01:00
Juergen Hoeller a2a9c47e59 Deprecate Velocity support
Issue: SPR-13235
2015-12-17 17:15:57 +01:00
Juergen Hoeller 8ce5e88c66 Require Jackson 2.6+, FreeMarker 2.3.21+, XStream 1.4.5+
Issue: SPR-13062
2015-12-17 17:14:50 +01:00