Example usage for org.eclipse.jgit.errors LargeObjectException.OutOfMemory setObjectId

List of usage examples for org.eclipse.jgit.errors LargeObjectException.OutOfMemory setObjectId

Introduction

In this page you can find the example usage for org.eclipse.jgit.errors LargeObjectException.OutOfMemory setObjectId.

Prototype

public void setObjectId(AnyObjectId id) 

Source Link

Document

Set the identity of the object, if its not already set.

Usage

From source file:MyDiffFormatter.java

License:Eclipse Distribution License

private byte[] open(DiffEntry.Side side, DiffEntry entry) throws IOException {
    if (entry.getMode(side) == FileMode.MISSING)
        return EMPTY;

    if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB)
        return EMPTY;

    AbbreviatedObjectId id = entry.getId(side);
    if (!id.isComplete()) {
        Collection<ObjectId> ids = reader.resolve(id);
        if (ids.size() == 1) {
            throw new IllegalStateException();
            //                id = AbbreviatedObjectId.fromObjectId(ids.iterator().next());
            //                switch (side) {
            //                    case OLD:
            //                        entry.oldId = id;
            //                        break;
            //                    case NEW:
            //                        entry.newId = id;
            //                        break;
            //                }
        } else if (ids.size() == 0)
            throw new MissingObjectException(id, Constants.OBJ_BLOB);
        else//from  ww  w.j  a  v a 2 s .  c o m
            throw new AmbiguousObjectException(id, ids);
    }

    try {
        ObjectLoader ldr = source.open(side, entry);
        int binaryFileThreshold = DEFAULT_BINARY_FILE_THRESHOLD;
        return ldr.getBytes(binaryFileThreshold);

    } catch (LargeObjectException.ExceedsLimit overLimit) {
        return BINARY;

    } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) {
        return BINARY;

    } catch (LargeObjectException.OutOfMemory tooBig) {
        return BINARY;

    } catch (LargeObjectException tooBig) {
        tooBig.setObjectId(id.toObjectId());
        throw tooBig;
    }
}

From source file:jbenchmarker.trace.git.GitExtraction.java

License:Open Source License

private byte[] getBytes(ObjectLoader ldr, ObjectId id) throws IOException {
    try {/*from w  w w  .j  av  a2 s .  c  o  m*/
        return ldr.getBytes(binaryFileThreshold);
    } catch (LargeObjectException.ExceedsLimit overLimit) {
        return BINARY;
    } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) {
        return BINARY;
    } catch (LargeObjectException.OutOfMemory tooBig) {
        return BINARY;
    } catch (LargeObjectException tooBig) {
        tooBig.setObjectId(id);
        throw tooBig;
    }
}