There should be no functional change, the logic updated only to make code simple so that compiler can understand what is going for. Removed all @SuppressWarnings("null") annotations since they cannot be used if "org.eclipse.jdt.core.compiler.problem.potentialNullReference" option is set to the "error" level. Bug: 470647 Change-Id: Ie93c249fa46e792198d362e531d5cbabaf41fdc4 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>tags/v4.1.0.201509280440-r
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning | org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning | ||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore | org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore | ||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error | org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error | ||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning | |||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=error | |||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore | org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore | ||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore | org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore | ||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning | org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning |
// The entry is contained in this subtree. | // The entry is contained in this subtree. | ||||
// | // | ||||
assert(st != null); | |||||
st.validate(cache, cCnt, cIdx, pathOff + st.nameLength() + 1); | st.validate(cache, cCnt, cIdx, pathOff + st.nameLength() + 1); | ||||
cIdx += st.entrySpan; | cIdx += st.entrySpan; | ||||
entrySpan += st.entrySpan; | entrySpan += st.entrySpan; |
return ByteBuffer.wrap(copyBuf, 0, bs); | return ByteBuffer.wrap(copyBuf, 0, bs); | ||||
} | } | ||||
@SuppressWarnings("null") | |||||
void copyAsIs(PackOutputStream out, DfsObjectToPack src, | void copyAsIs(PackOutputStream out, DfsObjectToPack src, | ||||
boolean validate, DfsReader ctx) throws IOException, | boolean validate, DfsReader ctx) throws IOException, | ||||
StoredObjectRepresentationNotAvailableException { | StoredObjectRepresentationNotAvailableException { | ||||
c = buf[headerCnt++] & 0xff; | c = buf[headerCnt++] & 0xff; | ||||
} while ((c & 128) != 0); | } while ((c & 128) != 0); | ||||
if (validate) { | if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, headerCnt); | crc1.update(buf, 0, headerCnt); | ||||
crc2.update(buf, 0, headerCnt); | crc2.update(buf, 0, headerCnt); | ||||
} | } | ||||
} else if (typeCode == Constants.OBJ_REF_DELTA) { | } else if (typeCode == Constants.OBJ_REF_DELTA) { | ||||
if (validate) { | if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, headerCnt); | crc1.update(buf, 0, headerCnt); | ||||
crc2.update(buf, 0, headerCnt); | crc2.update(buf, 0, headerCnt); | ||||
} | } | ||||
readFully(src.offset + headerCnt, buf, 0, 20, ctx); | readFully(src.offset + headerCnt, buf, 0, 20, ctx); | ||||
if (validate) { | if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, 20); | crc1.update(buf, 0, 20); | ||||
crc2.update(buf, 0, 20); | crc2.update(buf, 0, 20); | ||||
} | } | ||||
headerCnt += 20; | headerCnt += 20; | ||||
} else if (validate) { | } else if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, headerCnt); | crc1.update(buf, 0, headerCnt); | ||||
crc2.update(buf, 0, headerCnt); | crc2.update(buf, 0, headerCnt); | ||||
} | } | ||||
quickCopy = ctx.quickCopy(this, dataOffset, dataLength); | quickCopy = ctx.quickCopy(this, dataOffset, dataLength); | ||||
if (validate && idx(ctx).hasCRC32Support()) { | if (validate && idx(ctx).hasCRC32Support()) { | ||||
assert(crc1 != null); | |||||
// Index has the CRC32 code cached, validate the object. | // Index has the CRC32 code cached, validate the object. | ||||
// | // | ||||
expectedCRC = idx(ctx).findCRC32(src); | expectedCRC = idx(ctx).findCRC32(src); | ||||
Long.valueOf(src.offset), getPackName())); | Long.valueOf(src.offset), getPackName())); | ||||
} | } | ||||
} else if (validate) { | } else if (validate) { | ||||
assert(crc1 != null); | |||||
// We don't have a CRC32 code in the index, so compute it | // 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 | // now while inflating the raw data to get zlib to tell us | ||||
// whether or not the data is safe. | // whether or not the data is safe. | ||||
while (cnt > 0) { | while (cnt > 0) { | ||||
final int n = (int) Math.min(cnt, buf.length); | final int n = (int) Math.min(cnt, buf.length); | ||||
readFully(pos, buf, 0, n, ctx); | readFully(pos, buf, 0, n, ctx); | ||||
if (validate) | |||||
if (validate) { | |||||
assert(crc2 != null); | |||||
crc2.update(buf, 0, n); | crc2.update(buf, 0, n); | ||||
} | |||||
out.write(buf, 0, n); | out.write(buf, 0, n); | ||||
pos += n; | pos += n; | ||||
cnt -= n; | cnt -= n; | ||||
} | } | ||||
if (validate && crc2.getValue() != expectedCRC) { | |||||
throw new CorruptObjectException(MessageFormat.format( | |||||
JGitText.get().objectAtHasBadZlibStream, | |||||
Long.valueOf(src.offset), getPackName())); | |||||
if (validate) { | |||||
assert(crc2 != null); | |||||
if (crc2.getValue() != expectedCRC) { | |||||
throw new CorruptObjectException(MessageFormat.format( | |||||
JGitText.get().objectAtHasBadZlibStream, | |||||
Long.valueOf(src.offset), getPackName())); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
return buf.position(); | return buf.position(); | ||||
} | } | ||||
@SuppressWarnings("null") | |||||
ObjectLoader load(DfsReader ctx, long pos) | ObjectLoader load(DfsReader ctx, long pos) | ||||
throws IOException { | throws IOException { | ||||
try { | try { | ||||
if (data == null) | if (data == null) | ||||
throw new LargeObjectException(); | throw new LargeObjectException(); | ||||
assert(delta != null); | |||||
do { | do { | ||||
// Cache only the base immediately before desired object. | // Cache only the base immediately before desired object. | ||||
if (cached) | if (cached) |
} | } | ||||
} | } | ||||
@SuppressWarnings("null") | |||||
private void copyAsIs2(PackOutputStream out, LocalObjectToPack src, | private void copyAsIs2(PackOutputStream out, LocalObjectToPack src, | ||||
boolean validate, WindowCursor curs) throws IOException, | boolean validate, WindowCursor curs) throws IOException, | ||||
StoredObjectRepresentationNotAvailableException { | StoredObjectRepresentationNotAvailableException { | ||||
c = buf[headerCnt++] & 0xff; | c = buf[headerCnt++] & 0xff; | ||||
} while ((c & 128) != 0); | } while ((c & 128) != 0); | ||||
if (validate) { | if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, headerCnt); | crc1.update(buf, 0, headerCnt); | ||||
crc2.update(buf, 0, headerCnt); | crc2.update(buf, 0, headerCnt); | ||||
} | } | ||||
} else if (typeCode == Constants.OBJ_REF_DELTA) { | } else if (typeCode == Constants.OBJ_REF_DELTA) { | ||||
if (validate) { | if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, headerCnt); | crc1.update(buf, 0, headerCnt); | ||||
crc2.update(buf, 0, headerCnt); | crc2.update(buf, 0, headerCnt); | ||||
} | } | ||||
readFully(src.offset + headerCnt, buf, 0, 20, curs); | readFully(src.offset + headerCnt, buf, 0, 20, curs); | ||||
if (validate) { | if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, 20); | crc1.update(buf, 0, 20); | ||||
crc2.update(buf, 0, 20); | crc2.update(buf, 0, 20); | ||||
} | } | ||||
headerCnt += 20; | headerCnt += 20; | ||||
} else if (validate) { | } else if (validate) { | ||||
assert(crc1 != null && crc2 != null); | |||||
crc1.update(buf, 0, headerCnt); | crc1.update(buf, 0, headerCnt); | ||||
crc2.update(buf, 0, headerCnt); | crc2.update(buf, 0, headerCnt); | ||||
} | } | ||||
quickCopy = curs.quickCopy(this, dataOffset, dataLength); | quickCopy = curs.quickCopy(this, dataOffset, dataLength); | ||||
if (validate && idx().hasCRC32Support()) { | if (validate && idx().hasCRC32Support()) { | ||||
assert(crc1 != null); | |||||
// Index has the CRC32 code cached, validate the object. | // Index has the CRC32 code cached, validate the object. | ||||
// | // | ||||
expectedCRC = idx().findCRC32(src); | expectedCRC = idx().findCRC32(src); | ||||
if (quickCopy != null) { | if (quickCopy != null) { | ||||
quickCopy.check(inf, tmp, dataOffset, (int) dataLength); | quickCopy.check(inf, tmp, dataOffset, (int) dataLength); | ||||
} else { | } else { | ||||
assert(crc1 != null); | |||||
long pos = dataOffset; | long pos = dataOffset; | ||||
long cnt = dataLength; | long cnt = dataLength; | ||||
while (cnt > 0) { | while (cnt > 0) { | ||||
JGitText.get().shortCompressedStreamAt, | JGitText.get().shortCompressedStreamAt, | ||||
Long.valueOf(src.offset))); | Long.valueOf(src.offset))); | ||||
} | } | ||||
assert(crc1 != null); | |||||
expectedCRC = crc1.getValue(); | expectedCRC = crc1.getValue(); | ||||
} else { | } else { | ||||
expectedCRC = -1; | expectedCRC = -1; | ||||
while (cnt > 0) { | while (cnt > 0) { | ||||
final int n = (int) Math.min(cnt, buf.length); | final int n = (int) Math.min(cnt, buf.length); | ||||
readFully(pos, buf, 0, n, curs); | readFully(pos, buf, 0, n, curs); | ||||
if (validate) | |||||
if (validate) { | |||||
assert(crc2 != null); | |||||
crc2.update(buf, 0, n); | crc2.update(buf, 0, n); | ||||
} | |||||
out.write(buf, 0, n); | out.write(buf, 0, n); | ||||
pos += n; | pos += n; | ||||
cnt -= n; | cnt -= n; | ||||
} | } | ||||
if (validate && crc2.getValue() != expectedCRC) { | |||||
throw new CorruptObjectException(MessageFormat.format( | |||||
JGitText.get().objectAtHasBadZlibStream, | |||||
Long.valueOf(src.offset), getPackFile())); | |||||
if (validate) { | |||||
assert(crc2 != null); | |||||
if (crc2.getValue() != expectedCRC) { | |||||
throw new CorruptObjectException(MessageFormat.format( | |||||
JGitText.get().objectAtHasBadZlibStream, | |||||
Long.valueOf(src.offset), getPackFile())); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
, getPackFile())); | , getPackFile())); | ||||
} | } | ||||
@SuppressWarnings("null") | |||||
ObjectLoader load(final WindowCursor curs, long pos) | ObjectLoader load(final WindowCursor curs, long pos) | ||||
throws IOException, LargeObjectException { | throws IOException, LargeObjectException { | ||||
try { | try { | ||||
if (data == null) | if (data == null) | ||||
throw new IOException(JGitText.get().inMemoryBufferLimitExceeded); | throw new IOException(JGitText.get().inMemoryBufferLimitExceeded); | ||||
assert(delta != null); | |||||
do { | do { | ||||
// Cache only the base immediately before desired object. | // Cache only the base immediately before desired object. | ||||
if (cached) | if (cached) |
return n; | return n; | ||||
} | } | ||||
@SuppressWarnings("null") | |||||
private LooseRef scanRef(LooseRef ref, String name) throws IOException { | private LooseRef scanRef(LooseRef ref, String name) throws IOException { | ||||
final File path = fileFor(name); | final File path = fileFor(name); | ||||
FileSnapshot currentSnapshot = null; | FileSnapshot currentSnapshot = null; | ||||
final String target = RawParseUtils.decode(buf, 5, n); | final String target = RawParseUtils.decode(buf, 5, n); | ||||
if (ref != null && ref.isSymbolic() | if (ref != null && ref.isSymbolic() | ||||
&& ref.getTarget().getName().equals(target)) { | && ref.getTarget().getName().equals(target)) { | ||||
assert(currentSnapshot != null); | |||||
currentSnapshot.setClean(otherSnapshot); | currentSnapshot.setClean(otherSnapshot); | ||||
return ref; | return ref; | ||||
} | } | ||||
id = ObjectId.fromString(buf, 0); | id = ObjectId.fromString(buf, 0); | ||||
if (ref != null && !ref.isSymbolic() | if (ref != null && !ref.isSymbolic() | ||||
&& ref.getTarget().getObjectId().equals(id)) { | && ref.getTarget().getObjectId().equals(id)) { | ||||
assert(currentSnapshot != null); | |||||
currentSnapshot.setClean(otherSnapshot); | currentSnapshot.setClean(otherSnapshot); | ||||
return ref; | return ref; | ||||
} | } |