use of org.apache.commons.io.IOExceptionWithCause in project jackrabbit by apache.
the class BundleWriter method writeSmallBinary.
/**
* Write a small binary value and return the data.
*
* @param value the binary value
* @param state the property state (for error messages)
* @param i the index (for error messages)
* @return the data
* @throws IOException if the data could not be read
*/
private byte[] writeSmallBinary(InternalValue value, NodePropBundle.PropertyEntry state, int i) throws IOException {
try {
int size = (int) value.getLength();
out.writeInt(size);
byte[] data = new byte[size];
DataInputStream in = new DataInputStream(value.getStream());
try {
in.readFully(data);
} finally {
IOUtils.closeQuietly(in);
}
out.write(data, 0, data.length);
return data;
} catch (Exception e) {
String msg = "Error while storing blob. id=" + state.getId() + " idx=" + i + " value=" + value;
log.error(msg, e);
throw new IOExceptionWithCause(msg, e);
}
}
Aggregations