]
RH Bugzilla Integration commented on DROOLS-25:
-----------------------------------------------
Mario Fusco <mfusco(a)redhat.com> changed the Status of [bug
Cannot unmarshall large session file: InvalidProtocolBufferException
--------------------------------------------------------------------
Key: DROOLS-25
URL:
https://issues.jboss.org/browse/DROOLS-25
Project: Drools
Issue Type: Bug
Affects Versions: 5.5.0.Final
Environment: Jdk 7
Reporter: Magnus Vojbacke
Assignee: Edson Tirelli
Fix For: 5.5.1.Final, 6.0.0.Alpha9
When trying to unmarshall a large knowledge session from a file stream, an exception is
thrown.
It seems that there is a default message size limit in Protobuf (used by Drools
marshalling). Apparently, what happens is that the marshalled "Header" message
exceeds this size, which causes Protobuf to throw this exception.
I suspect that the Header field "payload" is the culprit, since it seems to
contain the rest of the knowledge base in byte array form.
Here's the stack trace:
{code:title=Stacktrace}
com.google.protobuf.InvalidProtocolBufferException: Protocol message was too large. May
be malicious. Use CodedInputStream.setSizeLimit() to increase the size limit.
at com.google.protobuf.InvalidProtocolBufferException.sizeLimitExceeded:89
at com.google.protobuf.CodedInputStream.refillBuffer:720
at com.google.protobuf.CodedInputStream.isAtEnd:666
at com.google.protobuf.CodedInputStream.readTag:99
at org.drools.marshalling.impl.ProtobufMessages$Header$Builder.mergeFrom:967
at org.drools.marshalling.impl.ProtobufMessages$Header$Builder.mergeFrom:773
at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom:212
at com.google.protobuf.AbstractMessage$Builder.mergeFrom:746
at org.drools.marshalling.impl.ProtobufMessages$Header.parseFrom:724
at org.drools.marshalling.impl.PersisterHelper.readFromStreamWithHeader:234
at org.drools.marshalling.impl.ProtobufInputMarshaller.loadAndParseSession:217
at org.drools.marshalling.impl.ProtobufInputMarshaller.readSession:107
at org.drools.marshalling.impl.ProtobufMarshaller.unmarshall:143
{code}
Suggested solutions:
#1
You can set the size limit of the Protobuf CodedInputStream, but there doesn't seem
to be any way of providing this parameter to the Drools unmarshalling API.
#2
When you unmarshall from a byte array, Protobuf does not enforce any message size limit.
I have successfully implemented a patch in drools-core that preloads the file into memory
and unmarshalls from a byte array. Probably the least desirable fix.