Search in sources :

Example 1 with BuildDataCorruptedException

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);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) IOException(java.io.IOException)

Example 2 with BuildDataCorruptedException

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);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) IOException(java.io.IOException) BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) IOException(java.io.IOException)

Example 3 with BuildDataCorruptedException

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);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) IOException(java.io.IOException)

Example 4 with BuildDataCorruptedException

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);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException)

Example 5 with BuildDataCorruptedException

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();
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) AtomicNotNullLazyValue(com.intellij.openapi.util.AtomicNotNullLazyValue) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

BuildDataCorruptedException (org.jetbrains.jps.builders.storage.BuildDataCorruptedException)26 IOException (java.io.IOException)8 PersistentHashMap (com.intellij.util.io.PersistentHashMap)4 File (java.io.File)4 THashSet (gnu.trove.THashSet)3 NotNull (org.jetbrains.annotations.NotNull)3 DataExternalizer (com.intellij.util.io.DataExternalizer)2 DataInputOutputUtil (com.intellij.util.io.DataInputOutputUtil)2 java.io (java.io)2 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)2 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)2 JpsModule (org.jetbrains.jps.model.module.JpsModule)2 AtomicNotNullLazyValue (com.intellij.openapi.util.AtomicNotNullLazyValue)1 Pair (com.intellij.openapi.util.Pair)1 Ref (com.intellij.openapi.util.Ref)1 Processor (com.intellij.util.Processor)1 MultiMap (com.intellij.util.containers.MultiMap)1 SLRUCache (com.intellij.util.containers.SLRUCache)1 KeyDescriptor (com.intellij.util.io.KeyDescriptor)1 MappingFailedException (com.intellij.util.io.MappingFailedException)1