Skip to content

Commit

Permalink
List of registered ext types must be listed by typeId, not class
Browse files Browse the repository at this point in the history
Because ext types for unpacker may be registered without class (just only with proc)
  • Loading branch information
tagomoris committed Oct 23, 2015
1 parent 6ee1b67 commit 654de1b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/java/org/msgpack/jruby/ExtensionRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public IRubyObject toInternalPackerRegistry(ThreadContext ctx) {

public IRubyObject toInternalUnpackerRegistry(ThreadContext ctx) {
RubyHash hash = RubyHash.newHash(ctx.getRuntime());
for (ExtensionEntry entry : extensionsByClass.values()) {
IRubyObject typeId = RubyFixnum.newFixnum(ctx.getRuntime(), entry.getTypeId());
if (entry.hasUnpacker()) {
for (int typeIdIndex = 0 ; typeIdIndex < 256 ; typeIdIndex++) {
ExtensionEntry entry = extensionsByTypeId[typeIdIndex];
if (entry != null && entry.hasUnpacker()) {
IRubyObject typeId = RubyFixnum.newFixnum(ctx.getRuntime(), typeIdIndex - 128);
hash.put(typeId, entry.toUnpackerTuple(ctx));
}
}
Expand Down

0 comments on commit 654de1b

Please sign in to comment.