Skip to content

Commit db16d5d

Browse files
authored
Merge pull request #406 from youdie006/symbol-unpacker-only-npe
Guard packerProc against a missing :packer key on JRuby
2 parents 4e2a755 + 72cda9b commit db16d5d

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

ext/java/org/msgpack/jruby/Factory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public IRubyObject registerTypeInternal(ThreadContext ctx, IRubyObject type, IRu
112112
extensionRegistry.put(extModule, (int) typeId, recursive, packerProc, unpackerProc);
113113

114114
if (extModule == runtime.getSymbol()) {
115-
hasSymbolExtType = !packerProc.isNil();
115+
hasSymbolExtType = packerProc != null && !packerProc.isNil();
116116
}
117117

118118
if (options != null) {

spec/factory_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ class MyType2 < MyType
273273
expect(factory.load(factory.dump(:foo))).to be == "foo"
274274
end
275275

276+
it 'handles Symbol type registered with only an unpacker' do
277+
factory = MessagePack::Factory.new
278+
factory.register_type(0x00, Symbol, unpacker: :to_sym.to_proc)
279+
expect(factory.load(factory.dump(:foo))).to be == "foo"
280+
end
281+
276282
describe "registering multiple ext type for the same class" do
277283
let(:payload) do
278284
factory = MessagePack::Factory.new

0 commit comments

Comments
 (0)