jrjackson 0.4.8-java → 0.4.13-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Rakefile +1 -1
- data/changelog.md +20 -0
- data/jrjackson.gemspec +2 -2
- data/lib/jrjackson/build_info.rb +9 -5
- 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 +18 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 799f68c6ec2b93e3885852b5199fc80dd0853381077f2ffec91bca46b7a6e1c9
|
4
|
+
data.tar.gz: 395b7a89c872e08482f776efd73d742de211c9e21a3057b164d8ee346dab7a31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa9023edcaea82e6235f5133bd3e8dc99d0329eb4ed258d63d17b0f213c5c7f13aa138140cf175c9681d08d5fab4102841230a7e843ef9c4d3177c22a50dc8a9
|
7
|
+
data.tar.gz: 05d0049ee65f6ae86f1e0e45209b8d4a9bcbd987f7684b50922944fb1759c9235f48998a6be764facd9270537aa7199bfc8a365c25377421c45987f1ec4642a9
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/changelog.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
v0.4.13
|
2
|
+
Bump jackson-databind to v2.9.10.6
|
3
|
+
|
4
|
+
v0.4.12
|
5
|
+
Bump jackson-databind to v2.9.10.4
|
6
|
+
|
7
|
+
v0.4.11
|
8
|
+
Bump Jackson to v2.9.10, and jackson-databind to v2.9.10.1
|
9
|
+
|
10
|
+
v0.4.10
|
11
|
+
fix concurrency issue when serializing dates.
|
12
|
+
Cache UTC TimeZone class to avoid unnecessary calls to synchronized method
|
13
|
+
Use a ThreadLocal to hold per-thread instances of SimpleDateFormat to avoid
|
14
|
+
unnecessary expensive clonings of that object
|
15
|
+
Replace unsafe call to setDateFormat on static ObjectMapper class by creating
|
16
|
+
an amended SerializationConfig
|
17
|
+
|
18
|
+
v0.4.9
|
19
|
+
bump Jackson to v2.9.9, and jackson-databind to v2.9.9.3
|
20
|
+
|
1
21
|
v0.4.8
|
2
22
|
fix serialisation of big numbers as Ruby 2.4 unifies Fixnum and Bignum into Integer
|
3
23
|
|
data/jrjackson.gemspec
CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.license = 'Apache License 2.0'
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_development_dependency 'bundler', '~> 1.10'
|
22
21
|
s.add_development_dependency 'jar-dependencies', '< 2.0', '>= 0.3.2'
|
23
22
|
|
24
23
|
jackson_version = JrJackson::BuildInfo.jackson_version
|
24
|
+
jackson_databind_version = JrJackson::BuildInfo.jackson_databind_version
|
25
25
|
s.requirements << "jar com.fasterxml.jackson.core:jackson-core, #{jackson_version}"
|
26
26
|
s.requirements << "jar com.fasterxml.jackson.core:jackson-annotations, #{jackson_version}"
|
27
|
-
s.requirements << "jar com.fasterxml.jackson.core:jackson-databind, #{
|
27
|
+
s.requirements << "jar com.fasterxml.jackson.core:jackson-databind, #{jackson_databind_version}"
|
28
28
|
s.requirements << "jar com.fasterxml.jackson.module:jackson-module-afterburner, #{jackson_version}"
|
29
29
|
|
30
30
|
s.files = JrJackson::BuildInfo.files
|
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.13'
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.release_date
|
8
|
-
'
|
8
|
+
'2020-10-26'
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.files
|
@@ -13,11 +13,15 @@ module JrJackson
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.jackson_version
|
16
|
-
'2.9.
|
16
|
+
'2.9.10'
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.jackson_databind_version
|
20
|
+
'2.9.10.6'
|
17
21
|
end
|
18
22
|
|
19
23
|
def self.jar_version
|
20
|
-
'1.2.
|
24
|
+
'1.2.31'
|
21
25
|
end
|
22
26
|
|
23
27
|
private
|
@@ -34,7 +38,7 @@ module JrJackson
|
|
34
38
|
[
|
35
39
|
"lib/com/fasterxml/jackson/core/jackson-annotations/#{jackson_version}/jackson-annotations-#{jackson_version}.jar",
|
36
40
|
"lib/com/fasterxml/jackson/core/jackson-core/#{jackson_version}/jackson-core-#{jackson_version}.jar",
|
37
|
-
"lib/com/fasterxml/jackson/core/jackson-databind/#{
|
41
|
+
"lib/com/fasterxml/jackson/core/jackson-databind/#{jackson_databind_version}/jackson-databind-#{jackson_databind_version}.jar",
|
38
42
|
"lib/com/fasterxml/jackson/module/jackson-module-afterburner/#{jackson_version}/jackson-module-afterburner-#{jackson_version}.jar",
|
39
43
|
"lib/jrjackson/jars/jrjackson-#{jar_version}.jar"
|
40
44
|
]
|
@@ -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,49 +1,35 @@
|
|
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.13
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Guy Boertje
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
17
|
-
- !ruby/object:Gem::Version
|
18
|
-
version: '1.10'
|
19
|
-
name: bundler
|
20
|
-
prerelease: false
|
21
|
-
type: :development
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
16
|
+
- - ">="
|
25
17
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
-
requirements:
|
18
|
+
version: 0.3.2
|
30
19
|
- - "<"
|
31
20
|
- !ruby/object:Gem::Version
|
32
21
|
version: '2.0'
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 0.3.2
|
36
22
|
name: jar-dependencies
|
37
|
-
prerelease: false
|
38
23
|
type: :development
|
24
|
+
prerelease: false
|
39
25
|
version_requirements: !ruby/object:Gem::Requirement
|
40
26
|
requirements:
|
41
|
-
- - "<"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '2.0'
|
44
27
|
- - ">="
|
45
28
|
- !ruby/object:Gem::Version
|
46
29
|
version: 0.3.2
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
47
33
|
description: A mostly native JRuby wrapper for the java jackson json processor jar
|
48
34
|
email:
|
49
35
|
- guyboertje@gmail.com
|
@@ -60,13 +46,13 @@ files:
|
|
60
46
|
- alt_bench.rb
|
61
47
|
- changelog.md
|
62
48
|
- jrjackson.gemspec
|
63
|
-
- lib/com/fasterxml/jackson/core/jackson-annotations/2.9.
|
64
|
-
- lib/com/fasterxml/jackson/core/jackson-core/2.9.
|
65
|
-
- lib/com/fasterxml/jackson/core/jackson-databind/2.9.
|
66
|
-
- lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.
|
49
|
+
- lib/com/fasterxml/jackson/core/jackson-annotations/2.9.10/jackson-annotations-2.9.10.jar
|
50
|
+
- lib/com/fasterxml/jackson/core/jackson-core/2.9.10/jackson-core-2.9.10.jar
|
51
|
+
- lib/com/fasterxml/jackson/core/jackson-databind/2.9.10.6/jackson-databind-2.9.10.6.jar
|
52
|
+
- lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.10/jackson-module-afterburner-2.9.10.jar
|
67
53
|
- lib/jrjackson.rb
|
68
54
|
- lib/jrjackson/build_info.rb
|
69
|
-
- lib/jrjackson/jars/jrjackson-1.2.
|
55
|
+
- lib/jrjackson/jars/jrjackson-1.2.31.jar
|
70
56
|
- lib/jrjackson/jrjackson.rb
|
71
57
|
- lib/jrjackson_jars.rb
|
72
58
|
- lib/require_relative_patch.rb
|
@@ -134,12 +120,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
120
|
- !ruby/object:Gem::Version
|
135
121
|
version: '0'
|
136
122
|
requirements:
|
137
|
-
- jar com.fasterxml.jackson.core:jackson-core, 2.9.
|
138
|
-
- jar com.fasterxml.jackson.core:jackson-annotations, 2.9.
|
139
|
-
- jar com.fasterxml.jackson.core:jackson-databind, 2.9.
|
140
|
-
- jar com.fasterxml.jackson.module:jackson-module-afterburner, 2.9.
|
141
|
-
|
142
|
-
rubygems_version: 2.7.6
|
123
|
+
- jar com.fasterxml.jackson.core:jackson-core, 2.9.10
|
124
|
+
- jar com.fasterxml.jackson.core:jackson-annotations, 2.9.10
|
125
|
+
- jar com.fasterxml.jackson.core:jackson-databind, 2.9.10.6
|
126
|
+
- jar com.fasterxml.jackson.module:jackson-module-afterburner, 2.9.10
|
127
|
+
rubygems_version: 3.0.6
|
143
128
|
signing_key:
|
144
129
|
specification_version: 4
|
145
130
|
summary: A JRuby wrapper for the java jackson json processor jar
|