jrjackson 0.4.9-java → 0.4.14-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Mavenfile +1 -7
- data/Rakefile +8 -2
- data/changelog.md +22 -2
- data/lib/jrjackson/build_info.rb +5 -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 +20 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f2727a3a05643d0112024c0b77e7ef313e0aa00a6ec2b210ff33e1f8ab664fc
|
4
|
+
data.tar.gz: ac5449253916c384b2ec2813bb9742f4ecc23ad5e14f5a20b931584c45f93d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ee252756aed46df8d924eef3cf14185085809465b8e28fd3afaf3c8787bc029144fe09f61bb189907923d873eb7156e084ac5d413fdefb77eb21b9d27845e9
|
7
|
+
data.tar.gz: 70e5bfded1449381236fcad1764a882a50b99381b8accca5ef326c856ae014ec7b8b17371008dd39fea6c558df118cea6d590c465f7c1c734aaf5a7c47ce8616
|
data/Mavenfile
CHANGED
@@ -14,7 +14,7 @@ properties 'project.build.sourceEncoding' => 'UTF-8',
|
|
14
14
|
|
15
15
|
jar 'junit:junit', '4.11', :scope => :test
|
16
16
|
|
17
|
-
jar 'org.jruby:jruby', '9.2.
|
17
|
+
jar 'org.jruby:jruby', '9.2.13.0', :scope => :provided
|
18
18
|
|
19
19
|
plugin :compiler, '3.1', :source => '1.8', :target => '1.8',
|
20
20
|
:showDeprecation => false,
|
@@ -23,9 +23,3 @@ plugin :compiler, '3.1', :source => '1.8', :target => '1.8',
|
|
23
23
|
:fork => true
|
24
24
|
|
25
25
|
plugin :surefire, '2.17', :skipTests => true
|
26
|
-
|
27
|
-
# since bundle install does not vendor our jars we need to it manually
|
28
|
-
plugin 'org.torquebox.mojo:jruby9-exec-maven-plugin', '0.3.1' do
|
29
|
-
execute_goal :exec, :id => 'vendor-jars', :phase => 'prepare-package',
|
30
|
-
:script => "require 'jars/installer';Jars::Installer.vendor_jars!"
|
31
|
-
end
|
data/Rakefile
CHANGED
@@ -10,12 +10,19 @@ end
|
|
10
10
|
|
11
11
|
desc "Run benchmarks"
|
12
12
|
task :benchmark do
|
13
|
-
load 'benchmarking/
|
13
|
+
load 'benchmarking/benchmark_threaded.rb'
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "Pack jar after compiling classes, use this to rebuild the pom.xml"
|
17
17
|
task :compile do
|
18
18
|
RubyMaven.exec('prepare-package')
|
19
|
+
# after packaging the jrjackson-x.y.z.jar vendor jar dependencies
|
20
|
+
Rake::Task['vendor_jars'].invoke
|
21
|
+
end
|
22
|
+
|
23
|
+
task :vendor_jars do
|
24
|
+
require 'jars/installer'
|
25
|
+
Jars::Installer.vendor_jars!
|
19
26
|
end
|
20
27
|
|
21
28
|
desc "Clean build"
|
@@ -30,4 +37,3 @@ Gem::PackageTask.new( eval File.read( 'jrjackson.gemspec' ) ) do
|
|
30
37
|
desc 'Pack gem'
|
31
38
|
task :package => [:compile]
|
32
39
|
end
|
33
|
-
|
data/changelog.md
CHANGED
@@ -1,8 +1,28 @@
|
|
1
|
+
v0.4.14
|
2
|
+
Bump jackson-databind to v2.9.10.8
|
3
|
+
|
4
|
+
v0.4.13
|
5
|
+
Bump jackson-databind to v2.9.10.6
|
6
|
+
|
7
|
+
v0.4.12
|
8
|
+
Bump jackson-databind to v2.9.10.4
|
9
|
+
|
10
|
+
v0.4.11
|
11
|
+
Bump Jackson to v2.9.10, and jackson-databind to v2.9.10.1
|
12
|
+
|
13
|
+
v0.4.10
|
14
|
+
fix concurrency issue when serializing dates.
|
15
|
+
Cache UTC TimeZone class to avoid unnecessary calls to synchronized method
|
16
|
+
Use a ThreadLocal to hold per-thread instances of SimpleDateFormat to avoid
|
17
|
+
unnecessary expensive clonings of that object
|
18
|
+
Replace unsafe call to setDateFormat on static ObjectMapper class by creating
|
19
|
+
an amended SerializationConfig
|
20
|
+
|
1
21
|
v0.4.9
|
2
22
|
bump Jackson to v2.9.9, and jackson-databind to v2.9.9.3
|
3
23
|
|
4
24
|
v0.4.8
|
5
|
-
fix serialisation of big numbers as Ruby 2.4 unifies Fixnum and Bignum into Integer
|
25
|
+
fix serialisation of big numbers as Ruby 2.4 unifies Fixnum and Bignum into Integer
|
6
26
|
|
7
27
|
v0.4.4
|
8
28
|
fix for issue 64
|
@@ -11,7 +31,7 @@ v0.4.4
|
|
11
31
|
v0.4.3
|
12
32
|
bump Jackson to v2.9.1
|
13
33
|
make static_mapper public
|
14
|
-
|
34
|
+
|
15
35
|
v0.4.1
|
16
36
|
fix for issue 55
|
17
37
|
Refactor AnySerializer acceptable class detection that does not use an exception
|
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.14'
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.release_date
|
8
|
-
'
|
8
|
+
'2021-01-06'
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.files
|
@@ -13,15 +13,15 @@ module JrJackson
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.jackson_version
|
16
|
-
'2.9.
|
16
|
+
'2.9.10'
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.jackson_databind_version
|
20
|
-
'2.9.
|
20
|
+
'2.9.10.8'
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.jar_version
|
24
|
-
'1.2.
|
24
|
+
'1.2.32'
|
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.14
|
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: 2021-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -17,8 +17,8 @@ dependencies:
|
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: '1.10'
|
19
19
|
name: bundler
|
20
|
-
prerelease: false
|
21
20
|
type: :development
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
@@ -27,23 +27,23 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2.0'
|
33
30
|
- - ">="
|
34
31
|
- !ruby/object:Gem::Version
|
35
32
|
version: 0.3.2
|
33
|
+
- - "<"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '2.0'
|
36
36
|
name: jar-dependencies
|
37
|
-
prerelease: false
|
38
37
|
type: :development
|
38
|
+
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - "<"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '2.0'
|
44
41
|
- - ">="
|
45
42
|
- !ruby/object:Gem::Version
|
46
43
|
version: 0.3.2
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
47
47
|
description: A mostly native JRuby wrapper for the java jackson json processor jar
|
48
48
|
email:
|
49
49
|
- guyboertje@gmail.com
|
@@ -60,13 +60,13 @@ files:
|
|
60
60
|
- alt_bench.rb
|
61
61
|
- changelog.md
|
62
62
|
- 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.
|
63
|
+
- lib/com/fasterxml/jackson/core/jackson-annotations/2.9.10/jackson-annotations-2.9.10.jar
|
64
|
+
- lib/com/fasterxml/jackson/core/jackson-core/2.9.10/jackson-core-2.9.10.jar
|
65
|
+
- lib/com/fasterxml/jackson/core/jackson-databind/2.9.10.8/jackson-databind-2.9.10.8.jar
|
66
|
+
- lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.10/jackson-module-afterburner-2.9.10.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.32.jar
|
70
70
|
- lib/jrjackson/jrjackson.rb
|
71
71
|
- lib/jrjackson_jars.rb
|
72
72
|
- lib/require_relative_patch.rb
|
@@ -134,12 +134,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
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
|
137
|
+
- jar com.fasterxml.jackson.core:jackson-core, 2.9.10
|
138
|
+
- jar com.fasterxml.jackson.core:jackson-annotations, 2.9.10
|
139
|
+
- jar com.fasterxml.jackson.core:jackson-databind, 2.9.10.8
|
140
|
+
- jar com.fasterxml.jackson.module:jackson-module-afterburner, 2.9.10
|
141
|
+
rubygems_version: 3.0.6
|
143
142
|
signing_key:
|
144
143
|
specification_version: 4
|
145
144
|
summary: A JRuby wrapper for the java jackson json processor jar
|