4Science / DSpace

This repository contains the 4Science optimized DSpace & DSpace-CRIS distribution.
https://wiki.lyrasis.org/display/DSPACECRIS/
BSD 3-Clause "New" or "Revised" License
44 stars 63 forks source link

SolrDedupServiceImpl: potential bug found in method cleanIndex #462

Open saschaszott opened 5 months ago

saschaszott commented 5 months ago

Bug Description

We found a potential bug in method cleanIndex:

https://github.com/4Science/DSpace/blob/04c7aa622a94e048a056dee462d8220592764971/dspace-api/src/main/java/org/dspace/app/deduplication/service/impl/SolrDedupServiceImpl.java#L637

Should this check be modified to i != null?

olli-gold commented 1 month ago

As far as I understand the code I would not say this is a bug. If there is an object in the index, which does not exist in the database, it's removed from the index. If it exists it should not be removed, as long as the index should not be erased completely. If it's expected to erase all of the index, this check is not needed at all and all objects should be unindexed (but I guess it does not make sense to erase the index by iterating through all objects).

So I don't think this is a bug and would guess it's intended as it is.

saschaszott commented 1 month ago

@olli-gold , thanks. That makes sense. I'll close the issue as won't fix.

saschaszott commented 1 month ago

@olli-gold , I have to reopen this issue.

If i is null, then in

https://github.com/4Science/DSpace/blob/04c7aa622a94e048a056dee462d8220592764971/dspace-api/src/main/java/org/dspace/app/deduplication/service/impl/SolrDedupServiceImpl.java#L642

the null value is passed as second method parameter.

Finally, this will result in a NullPointerException in

https://github.com/4Science/DSpace/blob/04c7aa622a94e048a056dee462d8220592764971/dspace-api/src/main/java/org/dspace/app/deduplication/service/impl/SolrDedupServiceImpl.java#L533

because of null object access in item.getID() and item.getType(). Do you agree?

olli-gold commented 1 month ago

Oh, yes, you are right. This is obviously a bug, which needs to be fixed.