Package org.eclipse.jgit.errors

Examples of org.eclipse.jgit.errors.CorruptObjectException


      // We need to read here to enter the loop above and pump the
      // trailing checksum into the Inflater. It should return -1 as the
      // caller was supposed to consume all content.
      //
      if (read(skipBuffer) != -1 || actualSize != expectedSize) {
        throw new CorruptObjectException(MessageFormat.format(JGitText
            .get().packfileCorruptionDetected,
            JGitText.get().wrongDecompressedLength));
      }

      int used = bAvail - inf.getRemaining();
View Full Code Here


    if (!biDirectionalPipe) {
      // Ensure the request was fully consumed. Any remaining input must
      // be a protocol error. If we aren't at EOF the implementation is broken.
      int eof = rawIn.read();
      if (0 <= eof)
        throw new CorruptObjectException(MessageFormat.format(
            JGitText.get().expectedEOFReceived,
            "\\x" + Integer.toHexString(eof)));
    }

    ProgressMonitor pm = NullProgressMonitor.INSTANCE;
View Full Code Here

    // protocols that embed a pack stream are required to either end their
    // stream with the pack, or embed the pack with a framing system like
    // the SideBandInputStream does.

    if (bAvail != 0)
      throw new CorruptObjectException(MessageFormat.format(
          JGitText.get().expectedEOFReceived,
          "\\x" + Integer.toHexString(buf[bOffset] & 0xff)));

    if (isCheckEofAfterPackFooter()) {
      int eof = in.read();
      if (0 <= eof)
        throw new CorruptObjectException(MessageFormat.format(
            JGitText.get().expectedEOFReceived,
            "\\x" + Integer.toHexString(eof)));
    }

    if (!Arrays.equals(actHash, srcHash))
      throw new CorruptObjectException(
          JGitText.get().corruptObjectPackfileChecksumIncorrect);

    onPackFooter(srcHash);
  }
View Full Code Here

    if (!biDirectionalPipe) {
      // Ensure the request was fully consumed. Any remaining input must
      // be a protocol error. If we aren't at EOF the implementation is broken.
      int eof = rawIn.read();
      if (0 <= eof)
        throw new CorruptObjectException(MessageFormat.format(
            JGitText.get().expectedEOFReceived,
            "\\x" + Integer.toHexString(eof)));
    }

    if (sideband) {
View Full Code Here

      case 'b':
        if (typeString[position + 1] != 'l'
            || typeString[position + 2] != 'o'
            || typeString[position + 3] != 'b'
            || typeString[position + 4] != endMark)
          throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
        offset.value = position + 5;
        return Constants.OBJ_BLOB;

      case 'c':
        if (typeString[position + 1] != 'o'
            || typeString[position + 2] != 'm'
            || typeString[position + 3] != 'm'
            || typeString[position + 4] != 'i'
            || typeString[position + 5] != 't'
            || typeString[position + 6] != endMark)
          throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
        offset.value = position + 7;
        return Constants.OBJ_COMMIT;

      case 't':
        switch (typeString[position + 1]) {
        case 'a':
          if (typeString[position + 2] != 'g'
              || typeString[position + 3] != endMark)
            throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
          offset.value = position + 4;
          return Constants.OBJ_TAG;

        case 'r':
          if (typeString[position + 2] != 'e'
              || typeString[position + 3] != 'e'
              || typeString[position + 4] != endMark)
            throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
          offset.value = position + 5;
          return Constants.OBJ_TREE;

        default:
          throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
        }

      default:
        throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
      }
    } catch (ArrayIndexOutOfBoundsException bad) {
      throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
    }
  }
View Full Code Here

            cnt -= n;
          }
        }
        if (crc1.getValue() != expectedCRC) {
          setCorrupt(src.offset);
          throw new CorruptObjectException(MessageFormat.format(
              JGitText.get().objectAtHasBadZlibStream,
              Long.valueOf(src.offset), getPackName()));
        }
      } else if (validate) {
        // We don't have a CRC32 code in the index, so compute it
        // now while inflating the raw data to get zlib to tell us
        // whether or not the data is safe.
        //
        Inflater inf = ctx.inflater();
        byte[] tmp = new byte[1024];
        if (quickCopy != null) {
          quickCopy.check(inf, tmp, dataOffset, (int) dataLength);
        } else {
          long pos = dataOffset;
          long cnt = dataLength;
          while (cnt > 0) {
            final int n = (int) Math.min(cnt, buf.length);
            readFully(pos, buf, 0, n, ctx);
            crc1.update(buf, 0, n);
            inf.setInput(buf, 0, n);
            while (inf.inflate(tmp, 0, tmp.length) > 0)
              continue;
            pos += n;
            cnt -= n;
          }
        }
        if (!inf.finished() || inf.getBytesRead() != dataLength) {
          setCorrupt(src.offset);
          throw new EOFException(MessageFormat.format(
              JGitText.get().shortCompressedStreamAt,
              Long.valueOf(src.offset)));
        }
        expectedCRC = crc1.getValue();
      } else {
        expectedCRC = -1;
      }
    } catch (DataFormatException dataFormat) {
      setCorrupt(src.offset);

      CorruptObjectException corruptObject = new CorruptObjectException(
          MessageFormat.format(
              JGitText.get().objectAtHasBadZlibStream,
              Long.valueOf(src.offset), getPackName()));
      corruptObject.initCause(dataFormat);

      StoredObjectRepresentationNotAvailableException gone;
      gone = new StoredObjectRepresentationNotAvailableException(src);
      gone.initCause(corruptObject);
      throw gone;

    } catch (IOException ioError) {
      StoredObjectRepresentationNotAvailableException gone;
      gone = new StoredObjectRepresentationNotAvailableException(src);
      gone.initCause(ioError);
      throw gone;
    }

    if (quickCopy != null) {
      // The entire object fits into a single byte array window slice,
      // and we have it pinned.  Write this out without copying.
      //
      out.writeHeader(src, inflatedLength);
      quickCopy.write(out, dataOffset, (int) dataLength, null);

    } else if (dataLength <= buf.length) {
      // Tiny optimization: Lots of objects are very small deltas or
      // deflated commits that are likely to fit in the copy buffer.
      //
      if (!validate) {
        long pos = dataOffset;
        long cnt = dataLength;
        while (cnt > 0) {
          final int n = (int) Math.min(cnt, buf.length);
          readFully(pos, buf, 0, n, ctx);
          pos += n;
          cnt -= n;
        }
      }
      out.writeHeader(src, inflatedLength);
      out.write(buf, 0, (int) dataLength);
    } else {
      // Now we are committed to sending the object. As we spool it out,
      // check its CRC32 code to make sure there wasn't corruption between
      // the verification we did above, and us actually outputting it.
      //
      out.writeHeader(src, inflatedLength);
      long pos = dataOffset;
      long cnt = dataLength;
      while (cnt > 0) {
        final int n = (int) Math.min(cnt, buf.length);
        readFully(pos, buf, 0, n, ctx);
        if (validate)
          crc2.update(buf, 0, n);
        out.write(buf, 0, n);
        pos += n;
        cnt -= n;
      }
      if (validate && crc2.getValue() != expectedCRC) {
        throw new CorruptObjectException(MessageFormat.format(
            JGitText.get().objectAtHasBadZlibStream,
            Long.valueOf(src.offset), getPackName()));
      }
    }
  }
View Full Code Here

      } while (delta != null);

      return new ObjectLoader.SmallObject(type, data);

    } catch (DataFormatException dfe) {
      CorruptObjectException coe = new CorruptObjectException(
          MessageFormat.format(
              JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
              getPackName()));
      coe.initCause(dfe);
      throw coe;
    }
  }
View Full Code Here

    }

    try {
      return BinaryDelta.getResultSize(getDeltaHeader(ctx, deltaAt));
    } catch (DataFormatException dfe) {
      CorruptObjectException coe = new CorruptObjectException(
          MessageFormat.format(
              JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
              getPackName()));
      coe.initCause(dfe);
      throw coe;
    }
  }
View Full Code Here

      }
      default:
        if (FileMode.GITLINK.equals(mode))
          break;
        treeWalk.getEntryObjectId(idBuffer);
        throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3
            , mode , idBuffer.name() , treeWalk.getEntryPathString() , currentTree.name()));
      }

      treeWalk = treeWalk.next();
    }
View Full Code Here

      }
      default:
        if (FileMode.GITLINK.equals(mode))
          break;
        treeWalk.getEntryObjectId(idBuffer);
        throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3
            , mode , idBuffer.name() , treeWalk.getEntryPathString() , tree));
      }

      treeWalk = treeWalk.next();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.errors.CorruptObjectException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.