Skip to content

Commit

Permalink
Fix #1408
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 16, 2019
1 parent ce60c1e commit ceed2dc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.9.8</version>
<version>2.9.9-SNAPSHOT</version>
</parent>

<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ Pavel Nikitin (morj@github)
* Requested #2181: Don't re-use dynamic serializers for property-updating copy constructors
(2.9.8)

Thomas Krieger (ThomasKrieger@github)
* Reported #1408: Call to `TypeVariable.getBounds()` without synchronization unsafe on
some platforms
(2.9.9)

René Kschamer (flawi@github)
* Reported #2197: Illegal reflective access operation warning when using `java.lang.Void`
as value type
Expand Down
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Project: jackson-databind
=== Releases ===
------------------------------------------------------------------------

2.9.9 (not yet released)

#1408: Call to `TypeVariable.getBounds()` without synchronization unsafe on some platforms
(reported by Thomas K)

2.9.8 (15-Dec-2018)

#1662: `ByteBuffer` serialization is broken if offset is not 0
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,9 @@ protected JavaType _fromVariable(ClassStack context, TypeVariable<?> var, TypeBi
{
// ideally should find it via bindings:
final String name = var.getName();
if (bindings == null) throw new Error("No Bindings!");
if (bindings == null) {
throw new IllegalArgumentException("Null `bindings` passed (type variable \""+name+"\")");
}
JavaType type = bindings.findBoundType(name);
if (type != null) {
return type;
Expand All @@ -1478,7 +1480,18 @@ protected JavaType _fromVariable(ClassStack context, TypeVariable<?> var, TypeBi
}
bindings = bindings.withUnboundVariable(name);

Type[] bounds = var.getBounds();
final Type[] bounds;

// 15-Jan-2019, tatu: As weird as this looks, apparently on some platforms (Arm CPU, mobile
// devices), unsynchronized internal access can lead to issues, see:
//
// https://vmlens.com/articles/java-lang-reflect-typevariable-getbounds-is-not-thread-safe/
//
// No good way to reproduce but since this should not be on critical path, let's add
// syncing as it seems potentially necessary.
synchronized (var) {
bounds = var.getBounds();
}
return _fromAny(context, bounds[0], bindings);
}

Expand Down

0 comments on commit ceed2dc

Please sign in to comment.