*/
private PushbackInputStream detectAndMarkMessageFault(final MessageContext messageContext,
final InputStream inputStream) throws IOException {
int bytesToRead = 4;
PushbackInputStream pis = new PushbackInputStream(inputStream, bytesToRead);
byte[] headerBytes = new byte[bytesToRead];
int n = pis.read(headerBytes);
// checking fourth byte for fault marker
if (n == bytesToRead) {
if (headerBytes[bytesToRead - 1] == HessianConstants.HESSIAN_V1_FAULT_IDENTIFIER
|| headerBytes[bytesToRead - 1] == HessianConstants.HESSIAN_V2_FAULT_IDENTIFIER) {
messageContext.setProperty(BaseConstants.FAULT_MESSAGE, SynapseConstants.TRUE);
if (log.isDebugEnabled()) {
log.debug("Hessian fault detected, marking in Axis2 message context");
}
}
pis.unread(headerBytes);
} else if (n > 0) {
byte[] bytesRead = new byte[n];
System.arraycopy(headerBytes, 0, bytesRead, 0, n);
pis.unread(bytesRead);
}
return pis;
}