use of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream in project intellij-community by JetBrains.
the class RadFormLayoutManager method createSerializedCopy.
private static Object createSerializedCopy(final Object original) {
// FormLayout may have been loaded with a different classloader, so we need to create a copy through serialization
Object copy;
try {
BufferExposingByteArrayOutputStream baos = new BufferExposingByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(baos);
try {
os.writeObject(original);
} finally {
os.close();
}
InputStream bais = new ByteArrayInputStream(baos.getInternalBuffer(), 0, baos.size());
ObjectInputStream is = new ObjectInputStream(bais);
try {
copy = is.readObject();
} finally {
is.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return copy;
}
use of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream in project intellij-community by JetBrains.
the class DiffContentRevision method getContentAsBytes.
@NotNull
@Override
public byte[] getContentAsBytes() throws VcsException {
if (myContents == null) {
BufferExposingByteArrayOutputStream bos = new BufferExposingByteArrayOutputStream(2048);
try {
myRepository.getFile(myPath, -1, null, bos);
myRepository.closeSession();
} catch (SVNException e) {
throw new VcsException(e);
}
myContents = bos.toByteArray();
}
return myContents;
}
use of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream in project intellij-community by JetBrains.
the class MavenProject method write.
public void write(@NotNull DataOutputStream out) throws IOException {
out.writeUTF(getPath());
BufferExposingByteArrayOutputStream bs = new BufferExposingByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bs);
try {
os.writeObject(myState);
out.writeInt(bs.size());
out.write(bs.getInternalBuffer(), 0, bs.size());
} finally {
os.close();
bs.close();
}
}
use of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream in project intellij-community by JetBrains.
the class SnapshotInputMappings method savePersistentData.
private boolean savePersistentData(Map<Key, Value> data, int id, boolean delayedReading) {
try {
if (delayedReading && myContents.containsMapping(id))
return false;
BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(ourSpareByteArray.getBuffer(4 * data.size()));
DataOutputStream stream = new DataOutputStream(out);
int size = data.size();
DataInputOutputUtil.writeINT(stream, size);
if (size > 0) {
THashMap<Value, List<Key>> values = new THashMap<>();
List<Key> keysForNullValue = null;
for (Map.Entry<Key, Value> e : data.entrySet()) {
Value value = e.getValue();
List<Key> keys = value != null ? values.get(value) : keysForNullValue;
if (keys == null) {
if (value != null)
values.put(value, keys = new SmartList<>());
else
keys = keysForNullValue = new SmartList<>();
}
keys.add(e.getKey());
}
if (keysForNullValue != null) {
myValueExternalizer.save(stream, null);
mySnapshotIndexExternalizer.save(stream, keysForNullValue);
}
for (Value value : values.keySet()) {
myValueExternalizer.save(stream, value);
mySnapshotIndexExternalizer.save(stream, values.get(value));
}
}
saveContents(id, out);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return true;
}
use of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream in project intellij-community by JetBrains.
the class AboutHttpService method execute.
@Nullable
@Override
public String execute(@NotNull QueryStringDecoder urlDecoder, @NotNull FullHttpRequest request, @NotNull ChannelHandlerContext context) throws IOException {
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") BufferExposingByteArrayOutputStream byteOut = new BufferExposingByteArrayOutputStream();
getAbout(byteOut, urlDecoder);
send(byteOut, request, context);
return null;
}
Aggregations