@@ -86,6 +86,8 @@ public class MessagePacker
8686{
8787 private final int smallStringOptimizationThreshold ;
8888
89+ private final int bufferFlushThreshold ;
90+
8991 protected MessageBufferOutput out ;
9092
9193 private MessageBuffer buffer ;
@@ -113,6 +115,7 @@ public MessagePacker(MessageBufferOutput out, MessagePack.PackerConfig config)
113115 this .out = checkNotNull (out , "MessageBufferOutput is null" );
114116 // We must copy the configuration parameters here since the config object is mutable
115117 this .smallStringOptimizationThreshold = config .smallStringOptimizationThreshold ;
118+ this .bufferFlushThreshold = config .bufferFlushThreshold ;
116119 this .position = 0 ;
117120 this .totalFlushBytes = 0 ;
118121 }
@@ -703,7 +706,7 @@ public MessagePacker writePayload(byte[] src)
703706 public MessagePacker writePayload (byte [] src , int off , int len )
704707 throws IOException
705708 {
706- if (buffer .size () - position < len || len > 8192 ) {
709+ if (buffer .size () - position < len || len > bufferFlushThreshold ) {
707710 flush (); // call flush before write
708711 out .write (src , off , len );
709712 totalFlushBytes += len ;
@@ -744,7 +747,7 @@ public MessagePacker addPayload(byte[] src)
744747 public MessagePacker addPayload (byte [] src , int off , int len )
745748 throws IOException
746749 {
747- if (buffer .size () - position < len || len > 8192 ) {
750+ if (buffer .size () - position < len || len > bufferFlushThreshold ) {
748751 flush (); // call flush before add
749752 out .add (src , off , len );
750753 totalFlushBytes += len ;
0 commit comments