jrjackson 0.4.9-java → 0.4.10-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Rakefile +1 -1
- data/changelog.md +8 -0
- data/lib/jrjackson/build_info.rb +3 -3
- data/src/main/java/com/jrjackson/RubyAnySerializer.java +4 -4
- data/src/main/java/com/jrjackson/RubyJacksonModule.java +18 -6
- data/test/jrjackson_test.rb +15 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d3369b8782272fc87ef0644bb444d6b16af249d7a2857f748b87fb93a9f804b
|
4
|
+
data.tar.gz: 61b413b82ec56c365737e64a46fe972a028c056f2dee601facde6d1c9687aa40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212cd2f25cc3bef4256882fb48a9ca338e3d415afa034d71368508b5117a5d19435799018b875f4a9fd2bb18b0c0eeca38a0bf9acbbbd8ce3f24fe85dfb18057
|
7
|
+
data.tar.gz: 6c5399b0a071d9a6609c1ec188018bae58b4dd1656be1f6185237c363fdfd5978ef93e75bd58ce8c4fdee2e79718bd9c5c58b0fe9312e4cca0609d2864943061
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/changelog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
v0.4.10
|
2
|
+
fix concurrency issue when serializing dates.
|
3
|
+
Cache UTC TimeZone class to avoid unnecessary calls to synchronized method
|
4
|
+
Use a ThreadLocal to hold per-thread instances of SimpleDateFormat to avoid
|
5
|
+
unnecessary expensive clonings of that object
|
6
|
+
Replace unsafe call to setDateFormat on static ObjectMapper class by creating
|
7
|
+
an amended SerializationConfig
|
8
|
+
|
1
9
|
v0.4.9
|
2
10
|
bump Jackson to v2.9.9, and jackson-databind to v2.9.9.3
|
3
11
|
|
data/lib/jrjackson/build_info.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module JrJackson
|
2
2
|
module BuildInfo
|
3
3
|
def self.version
|
4
|
-
'0.4.
|
4
|
+
'0.4.10'
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.release_date
|
8
|
-
'2019-
|
8
|
+
'2019-09-25'
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.files
|
@@ -21,7 +21,7 @@ module JrJackson
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.jar_version
|
24
|
-
'1.2.
|
24
|
+
'1.2.28'
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
@@ -234,13 +234,13 @@ public class RubyAnySerializer extends JsonSerializer<IRubyObject> {
|
|
234
234
|
if (df == null) {
|
235
235
|
// DateFormat should always be set
|
236
236
|
provider.defaultSerializeDateValue(dt.getJavaDate(), jgen);
|
237
|
-
}
|
237
|
+
} // RWB Note: I believe this is no longer used
|
238
|
+
else if (df instanceof RubyDateFormat) {
|
238
239
|
// why another branch? I thought there was an easy win on to_s
|
239
240
|
// maybe with jruby 9000
|
240
|
-
RubyDateFormat
|
241
|
-
jgen.writeString(
|
241
|
+
RubyDateFormat clonedRubyDateFormat = (RubyDateFormat) df.clone();
|
242
|
+
jgen.writeString(clonedRubyDateFormat.format(dt.getJavaDate()));
|
242
243
|
} else {
|
243
|
-
SimpleDateFormat sdf = (SimpleDateFormat) df.clone();
|
244
244
|
jgen.writeString(df.format(dt.getJavaDate()));
|
245
245
|
}
|
246
246
|
}
|
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.Version;
|
|
5
5
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
6
6
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
7
7
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
8
|
+
import com.fasterxml.jackson.databind.SerializationConfig;
|
8
9
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
9
10
|
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
|
10
11
|
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
|
@@ -17,6 +18,16 @@ import java.util.TimeZone;
|
|
17
18
|
public class RubyJacksonModule extends SimpleModule {
|
18
19
|
public static final ObjectMapper static_mapper = new ObjectMapper();
|
19
20
|
public static final JsonFactory factory = new JsonFactory(static_mapper).disable(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW);
|
21
|
+
private static final TimeZone utcTimeZone = TimeZone.getTimeZone("UTC");
|
22
|
+
|
23
|
+
private static final ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat> () {
|
24
|
+
@Override
|
25
|
+
protected SimpleDateFormat initialValue() {
|
26
|
+
SimpleDateFormat rdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
|
27
|
+
rdf.setTimeZone(utcTimeZone);
|
28
|
+
return rdf;
|
29
|
+
}
|
30
|
+
};
|
20
31
|
|
21
32
|
static {
|
22
33
|
static_mapper.registerModule(new RubyJacksonModule().addSerializer(
|
@@ -27,7 +38,7 @@ public class RubyJacksonModule extends SimpleModule {
|
|
27
38
|
}
|
28
39
|
|
29
40
|
private RubyJacksonModule() {
|
30
|
-
super("JrJacksonStrModule", new Version(1, 2,
|
41
|
+
super("JrJacksonStrModule", new Version(1, 2, 28, "0", "com.jrjackson.jruby", "jrjackson"));
|
31
42
|
}
|
32
43
|
|
33
44
|
public static ObjectMapper mapperWith(Ruby ruby, RubyKeyConverter nameConverter,
|
@@ -46,17 +57,18 @@ public class RubyJacksonModule extends SimpleModule {
|
|
46
57
|
}
|
47
58
|
|
48
59
|
public static DefaultSerializerProvider createProvider(SimpleDateFormat sdf) {
|
49
|
-
|
60
|
+
// Use a copy of the SerializationConfig to avoid calling setDateFormat on the static ObjectMapper
|
61
|
+
// object, removing its thread safety properties. In future, we might want to think about doing
|
62
|
+
// a refactor to use ObjectWriters instead of modifying serialization configs.
|
63
|
+
SerializationConfig config = static_mapper.getSerializationConfig().with(sdf);
|
50
64
|
return ((DefaultSerializerProvider) static_mapper.getSerializerProvider()).createInstance(
|
51
|
-
|
65
|
+
config,
|
52
66
|
static_mapper.getSerializerFactory()
|
53
67
|
);
|
54
68
|
}
|
55
69
|
|
56
70
|
public static DefaultSerializerProvider createProvider() {
|
57
|
-
|
58
|
-
rdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
59
|
-
return createProvider(rdf);
|
71
|
+
return createProvider(dateFormat.get());
|
60
72
|
}
|
61
73
|
|
62
74
|
public static ObjectMapper rawBigNumberMapper() {
|
data/test/jrjackson_test.rb
CHANGED
@@ -548,6 +548,21 @@ class JrJacksonTest < Test::Unit::TestCase
|
|
548
548
|
assert_equal "{\"foo\":9223372036854775808,\"bar\":65536}", actual
|
549
549
|
end
|
550
550
|
|
551
|
+
|
552
|
+
# This test failed more often than not before fixing the underlying code
|
553
|
+
# and would fail every time if `100_000.times` was changed to `loop`
|
554
|
+
def test_concurrent_dump
|
555
|
+
now = Time.now
|
556
|
+
num_threads = 100
|
557
|
+
|
558
|
+
threads = num_threads.times.map do |i|
|
559
|
+
Thread.new do
|
560
|
+
100_000.times { JrJackson::Json.dump("a" => now) }
|
561
|
+
end
|
562
|
+
end
|
563
|
+
threads.each(&:join)
|
564
|
+
end
|
565
|
+
|
551
566
|
# -----------------------------
|
552
567
|
|
553
568
|
def assert_bigdecimal_equal(expected, actual)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jrjackson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Guy Boertje
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ files:
|
|
66
66
|
- lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.9/jackson-module-afterburner-2.9.9.jar
|
67
67
|
- lib/jrjackson.rb
|
68
68
|
- lib/jrjackson/build_info.rb
|
69
|
-
- lib/jrjackson/jars/jrjackson-1.2.
|
69
|
+
- lib/jrjackson/jars/jrjackson-1.2.28.jar
|
70
70
|
- lib/jrjackson/jrjackson.rb
|
71
71
|
- lib/jrjackson_jars.rb
|
72
72
|
- lib/require_relative_patch.rb
|
@@ -139,7 +139,7 @@ requirements:
|
|
139
139
|
- jar com.fasterxml.jackson.core:jackson-databind, 2.9.9.3
|
140
140
|
- jar com.fasterxml.jackson.module:jackson-module-afterburner, 2.9.9
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.6.13
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: A JRuby wrapper for the java jackson json processor jar
|