return null;
}
int dataLen = buffer.getInt(buffer.readerIndex());
if (dataLen <= 0) {
throw new StreamCorruptedException("invalid data length: " + dataLen);
}
if (dataLen > maxObjectSize) {
throw new StreamCorruptedException(
"data length too big: " + dataLen + " (max: " + maxObjectSize + ')');
}
if (buffer.readableBytes() < dataLen + 4) {
return null;
}
buffer.skipBytes(4);
CompactObjectInputStream cois = new CompactObjectInputStream(
new ChannelBufferInputStream(buffer, dataLen), classLoader);
result = cois.readObject();
streams = ExternalizeUtil.readList(cois, StreamFactoryReference.class);
streamIndex = 0;
}
while (streamIndex < streams.size()) {
if (buffer.readableBytes() < 2) {
return null;
}
int dataLen = buffer.getShort(buffer.readerIndex()) & 0xffff;
if (buffer.readableBytes() < dataLen + 2) {
return null;
}
buffer.skipBytes(2);
if (stream == null) {
store = storageManager.createFileStore("temp-stream"); //$NON-NLS-1$
StreamFactoryReference sfr = streams.get(streamIndex);
sfr.setStreamFactory(new FileStoreInputStreamFactory(store, Streamable.ENCODING));
this.stream = new BufferedOutputStream(store.createOutputStream());
}
if (dataLen == 0) {
stream.close();
stream = null;
streamIndex++;
continue;
}
if (store.getLength() + dataLen > MAX_LOB_SIZE) {
throw new StreamCorruptedException(
"lob too big: " + store.getLength() + dataLen + " (max: " + MAX_LOB_SIZE + ')');
}
buffer.readBytes(this.stream, dataLen);
}
Object toReturn = result;