use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.
the class ParamAnnotation method save.
@Override
public void save(DataOutput out) {
try {
DataInputOutputUtil.writeINT(out, paramIndex);
type.save(out);
} catch (IOException e) {
throw new BuildDataCorruptedException(e);
}
}
use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.
the class ProtoMember method save.
public void save(final DataOutput out) {
super.save(out);
myType.save(out);
try {
final Object val = myValue;
final Class valueType = val != null ? val.getClass() : null;
if (valueType != null && valueType.isArray()) {
final int length = Array.getLength(val);
final Class dataType = length > 0 ? Array.get(val, 0).getClass() : valueType.getComponentType();
final DataDescriptor descriptor = DataDescriptor.findByValueType(dataType);
out.writeByte(-descriptor.getId());
if (descriptor != DataDescriptor.NONE) {
DataInputOutputUtil.writeINT(out, length);
for (int idx = 0; idx < length; idx++) {
final Object element = Array.get(val, idx);
//noinspection unchecked
descriptor.save(out, element);
}
}
} else {
final DataDescriptor descriptor = DataDescriptor.findByValueType(valueType);
out.writeByte(descriptor.getId());
//noinspection unchecked
descriptor.save(out, val);
}
} catch (IOException e) {
throw new BuildDataCorruptedException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.
the class ProtoMember method loadTyped.
private static Object loadTyped(final DataInput in) {
try {
final byte tag = in.readByte();
if (tag < 0) {
// is array
final int length = DataInputOutputUtil.readINT(in);
final DataDescriptor descriptor = DataDescriptor.findById((byte) -tag);
final Object array = Array.newInstance(descriptor.getDataType(), length);
for (int idx = 0; idx < length; idx++) {
Array.set(array, idx, descriptor.load(in));
}
return array;
}
return DataDescriptor.findById(tag).load(in);
} catch (IOException e) {
throw new BuildDataCorruptedException(e);
}
}
use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.
the class RW method save.
public static <X> void save(final TIntHashSet x, final DataOutput out) {
try {
DataInputOutputUtil.writeINT(out, x.size());
x.forEach(value -> {
try {
DataInputOutputUtil.writeINT(out, value);
return true;
} catch (IOException e) {
throw new BuildDataCorruptedException(e);
}
});
} catch (IOException c) {
throw new BuildDataCorruptedException(c);
}
}
use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.
the class BuildTargetStorages method getOrCreateStorage.
@NotNull
public <S extends StorageOwner> S getOrCreateStorage(@NotNull final StorageProvider<S> provider) throws IOException {
NotNullLazyValue<? extends StorageOwner> lazyValue = myStorages.get(provider);
if (lazyValue == null) {
AtomicNotNullLazyValue<S> newValue = new AtomicNotNullLazyValue<S>() {
@NotNull
@Override
protected S compute() {
try {
return provider.createStorage(myPaths.getTargetDataRoot(myTarget));
} catch (IOException e) {
throw new BuildDataCorruptedException(e);
}
}
};
lazyValue = myStorages.putIfAbsent(provider, newValue);
if (lazyValue == null) {
// just initialized
lazyValue = newValue;
}
}
//noinspection unchecked
try {
return (S) lazyValue.getValue();
} catch (BuildDataCorruptedException e) {
throw e.getCause();
}
}
Aggregations