@@ -85,15 +85,24 @@ public static SecurityQueryPayload parseBinaryQueryHeader(byte[] binHeader) {
8585 }
8686
8787 public byte [] assembleSecurityQueryPayload (int payloadSize ) {
88- byte [] payLoad = new byte [SECURITY_QUERY_HEADER_SIZE + payloadSize ];
89- System .arraycopy (assembleHeaderBytes (), 0 , payLoad , 0 , SECURITY_QUERY_HEADER_SIZE );
90-
88+ byte [] payLoad = new byte [SECURITY_QUERY_HEADER_SIZE ];
9189 if (_securityQueryID == SecurityQueryID .SEND_INTERNAL_ERROR && _securityQueryType == SecurityQueryType .NOTIFICATION ) {
90+ payLoad = new byte [SECURITY_QUERY_HEADER_SIZE + payloadSize + 1 ];
9291 System .arraycopy (_jsonData , 0 , payLoad , SECURITY_QUERY_HEADER_SIZE , _jsonSize );
92+ byte [] errorCode = new byte [1 ];
93+ if (this ._errorCode != null ) {
94+ errorCode [0 ] = _errorCode .getValue ();
95+ } else {
96+ errorCode [0 ] = SecurityQueryErrorCode .ERROR_UNKNOWN_INTERNAL_ERROR .getValue ();
97+ }
98+ System .arraycopy (errorCode , 0 , payLoad , payLoad .length - 1 , 1 );
9399 } else if (_securityQueryID == SecurityQueryID .SEND_HANDSHAKE_DATA && _securityQueryType == SecurityQueryType .RESPONSE ) {
100+ payLoad = new byte [SECURITY_QUERY_HEADER_SIZE + payloadSize ];
94101 System .arraycopy (_bulkData , 0 , payLoad , SECURITY_QUERY_HEADER_SIZE , payloadSize );
95102 }
96103
104+ System .arraycopy (assembleHeaderBytes (), 0 , payLoad , 0 , SECURITY_QUERY_HEADER_SIZE );
105+
97106 return payLoad ;
98107 }
99108
0 commit comments