Skip to content

I20201105-1800

@trancexpress trancexpress tagged this 05 Nov 22:52
During JDT indexing of a project its possible that the project is
deleted in parallel, deleting also index files for that project. With
bad ordering, the indexing can save a "stale" index file after the
project is deleted. Re-creating the project and deleting it again (e.g.
during tests) can result in DiskIndex throwing an
ArrayIndexOutOfBoundsException (AIOOBE).

In particular, the AIOOBE is caused by reading a bad value (-1) for
DiskIndex.bufferEnd, due to the deleted index file. As a result
DiskIndex.readStreamBuffer() will return without resetting
DiskIndex.bufferIndex to 0, when the end of DiskIndex.streamBuffer is
reached. DiskIndex.readChunk() will then increment
DiskIndex.bufferIndex() past the length of the buffer, accessing an
invalid index with the next operation and so throwing an exception.

This change ensures an IOException is thrown in case DiskIndex.bufferEnd
has a bad value and the input stream of DiskIndex has no more available
data to read. An IOException is already handled by JDT, unlike an
AIOOBE.

Change-Id: I1c95d87faf1bf01348c602fb721be1b85b8a7306
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
Assets 2
Loading