Skip to content

Commit

Permalink
Use jar deps, fix mem prob, no symbol table excep, ser ruby date
Browse files Browse the repository at this point in the history
post jar dependencies

final update for 0.3.9

add support for date

Fixes #47
Fixes #50
Fixes #51

Punctuation.

Fixes #47
Fixes #50
Fixes #51
  • Loading branch information
guyboertje committed Apr 11, 2016
1 parent b365d16 commit 48f9e18
Show file tree
Hide file tree
Showing 24 changed files with 336 additions and 164 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Rakefile.old

linked
/libyjpagent.so
/.project
2 changes: 1 addition & 1 deletion Mavenfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#-*- mode: ruby -*-

VERSION='1.2.17'
VERSION='1.2.18'
gemspec :jar => "jrjackson/jars/jrjackson-#{VERSION}.jar"

# overwrite groupId:artifacgtId:version from gem
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The options hash respects three symbol keys

+ :use_bigdecimal

Will return BigDecimal objects instead of Float
Will return BigDecimal objects instead of Float.
If used with the :raw option you will get Java::JavaMath::BigDecimal objects
otherwise they are Ruby BigDecimal

Expand Down
6 changes: 0 additions & 6 deletions benchmarking/individual/raw-jr-sourced.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,3 @@
BenchOptions.iterations.times { JrJackson::Java.parse(dumped_string, opts) }
end
end

Benchmark.bmbm(BenchOptions.output_width) do |x|
x.report("jackson parse ruby compat: #{BenchOptions.iterations}") do
BenchOptions.iterations.times { JrJackson::Ruby.compat_parse(dumped_string, {}) }
end
end
10 changes: 9 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
v0.3.9
Thanks to mkristian, now uses jar_dependencies
Upgrade to Jackson v2.7.1
fix for issue 51
dont create "new RubyJacksonModule()" when creating a Provider
fix for reports of symbol table overflow in Jackson when using JrJackson in very long running daemons (Logstash)
disable the FAIL_ON_SYMBOL_HASH_OVERFLOW setting

v0.3.8
fix for issue 47
Update Jackson to v 0.6.3
Update Jackson to v 2.6.3
Change error message to better report failure in issue 46

v0.3.7
Expand Down
2 changes: 1 addition & 1 deletion jrjackson.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'jar-dependencies', '< 2.0', '>= 0.3.2'
s.add_development_dependency 'ruby-maven', '~>3.3.10'

JACKSON_VERSION = '2.6.3'
JACKSON_VERSION = '2.7.1'
s.requirements << "jar com.fasterxml.jackson.core:jackson-core, #{JACKSON_VERSION}"
s.requirements << "jar com.fasterxml.jackson.core:jackson-annotations, #{JACKSON_VERSION}"
s.requirements << "jar com.fasterxml.jackson.core:jackson-databind, #{JACKSON_VERSION}"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/jrjackson/build_info.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module JrJackson
module BuildInfo
def self.version
'0.3.8'
'0.3.9'
end

def self.release_date
'2015-12-10'
'2016-04-09'
end

def self.files
Expand Down
Binary file removed lib/jrjackson/jars/jrjackson-1.2.17.jar
Binary file not shown.
Binary file added lib/jrjackson/jars/jrjackson-1.2.18.jar
Binary file not shown.
10 changes: 6 additions & 4 deletions lib/jrjackson/jrjackson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
exit 255
end

require_relative "jars/jrjackson-1.2.17.jar"
require_relative '../jrjackson_jars'
# require_relative "linked/jrjackson-1.2.17.jar"
require "jrjackson_jars"

require_relative "jars/jrjackson-1.2.18.jar"

require 'com/jrjackson/jr_jackson'
require 'bigdecimal'
Expand Down Expand Up @@ -63,7 +63,9 @@ def dump(object, options = {})
when nil
'null'
else
if object.respond_to?(:to_json)
if object.respond_to?(:to_json_data)
JrJackson::Base.generate(object, options)
elsif object.respond_to?(:to_json)
object.to_json
elsif object.respond_to?(:to_s)
object.to_s
Expand Down
8 changes: 4 additions & 4 deletions lib/jrjackson_jars.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# this is a generated file, to avoid over-writing it just delete this comment
require 'jar_dependencies'

require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.6.3' )
require_jar( 'com.fasterxml.jackson.module', 'jackson-module-afterburner', '2.6.3' )
require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.6.3' )
require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.6.3' )
require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.7.1' )
require_jar( 'com.fasterxml.jackson.module', 'jackson-module-afterburner', '2.7.1' )
require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.7.1' )
require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.7.1' )
193 changes: 193 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT MODIFIY - GENERATED CODE
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jrjackson.jruby</groupId>
<artifactId>jrjackson</artifactId>
<version>1.2.18</version>
<name>A JRuby wrapper for the java jackson json processor jar</name>
<description>A mostly native JRuby wrapper for the java jackson json processor jar</description>
<url>http://github.com/guyboertje/jrjackson</url>
<licenses>
<license>
<name>Apache License 2.0</name>
</license>
</licenses>
<developers>
<developer>
<name>Guy Boertje</name>
<email>guyboertje@gmail.com</email>
</developer>
</developers>
<scm>
<connection>https://github.com/guyboertje/jrjackson.git</connection>
<url>http://github.com/guyboertje/jrjackson</url>
</scm>
<properties>
<netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
<mavengem.wagon.version>0.2.0</mavengem.wagon.version>
<jruby.plugins.version>1.1.4</jruby.plugins.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>rubygems</groupId>
<artifactId>bundler</artifactId>
<version>[1.10,1.99999]</version>
<type>gem</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>jar-dependencies</artifactId>
<version>[0.3.2,2.0)</version>
<type>gem</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>ruby-maven</artifactId>
<version>[3.3.10,3.3.99999]</version>
<type>gem</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-afterburner</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
<version>9.0.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mavengems</id>
<url>mavengem:https://rubygems.org</url>
</repository>
</repositories>
<build>
<extensions>
<extension>
<groupId>org.torquebox.mojo</groupId>
<artifactId>mavengem-wagon</artifactId>
<version>${mavengem.wagon.version}</version>
</extension>
<extension>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-with-jar-extension</artifactId>
<version>${jruby.plugins.version}</version>
</extension>
</extensions>
<directory>${basedir}/pkg</directory>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>lib/jrjackson/jars</outputDirectory>
<finalName>jrjackson-1.2.18</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4</version>
<configuration>
<filesets>
<fileset>
<directory>lib/jrjackson/jars</directory>
<includes>
<include>jrjackson-1.2.18.jar</include>
<include>*/**/*.jar</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>${jruby.plugins.version}</version>
<configuration>
<gemspec>jrjackson.gemspec</gemspec>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<showDeprecateion>false</showDeprecateion>
<showWarnings>false</showWarnings>
<executable>${JAVA_HOME}/bin/javac</executable>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.torquebox.mojo</groupId>
<artifactId>jruby9-exec-maven-plugin</artifactId>
<version>0.3.1</version>
<executions>
<execution>
<id>vendor-jars</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<script>require 'jars/installer';Jars::Installer.vendor_jars!</script>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
16 changes: 7 additions & 9 deletions src/main/java/com/jrjackson/JrJacksonBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.ByteArrayOutputStream;
import org.jruby.RubyHash;
import org.jruby.RubyIO;
Expand All @@ -37,8 +38,6 @@
*/
public class JrJacksonBase extends RubyObject {

private static final SimpleDateFormat RDF = new RubyDateFormat("yyyy-MM-dd HH:mm:ss Z");

// serialize
@JRubyMethod(module = true, name = {"generate", "dump"}, required = 1, optional = 1)
public static IRubyObject generate(ThreadContext context, IRubyObject self, IRubyObject[] args)
Expand All @@ -55,21 +54,20 @@ public static IRubyObject generate(ThreadContext context, IRubyObject self, IRub
jgen.useDefaultPrettyPrinter();
}

SimpleDateFormat simpleFormat;
SerializerProvider provider;
if (format != null) {
simpleFormat = new SimpleDateFormat(format);
SimpleDateFormat simpleFormat = new SimpleDateFormat(format);
String timezone = (String) options.get(RubyUtils.rubySymbol(_ruby, "timezone"));
if (timezone != null) {
simpleFormat.setTimeZone(TimeZone.getTimeZone(timezone));
}
provider = RubyJacksonModule.createProvider(simpleFormat);
} else {
// using a 'marker' class instance, will not use later but default to #to_s
simpleFormat = RDF;
provider = RubyJacksonModule.createProvider();
}

try {
RubyAnySerializer.instance.serialize(args[0], jgen,
RubyJacksonModule.createProvider(simpleFormat));
RubyAnySerializer.instance.serialize(args[0], jgen, provider);
jgen.close();
ByteList bl = new ByteList(baos.toByteArray(),
UTF8Encoding.INSTANCE);
Expand All @@ -89,7 +87,7 @@ protected static boolean flagged(RubyHash opts, RubySymbol key) {
}

protected static boolean flagged(RubyHash opts, RubySymbol key, boolean returnVal) {
if(!opts.containsKey(key)) {
if (!opts.containsKey(key)) {
return returnVal;
}
Object val = opts.get(key);
Expand Down
Loading

0 comments on commit 48f9e18

Please sign in to comment.