Closed LuQQiu closed 3 years ago
DefaultBlockStoreMeta
constructor has a parameter shouldIncludeBlockIds
which means getBlockStoreMeta
or getBlockStoreMetaFull
. When we don't need to get full meta, mBlockIdsOnTiers
and mBlockIdsOnLocations
will not be initialized.
Why did the previous author add checkNotNull
?
I guess:
getBlockList()
is meaningless when we don't get full metadata (it cannot be used without being initialized). This can avoid some misuse i think.
null
and empty
is different. one is not initialized and one is that doesn't have any blocks inside.
if we want to use getBlockList()
,we need to make sure that we had got full metadata (use getBlockStoreMetaFull
instead of getBlockStoreMeta
).
Got it, so the CheckNotNull makes sense if getBlockMeta is used instead of getBlockMetaFull. Can you create a PR to modify the description of BlockStoreMeta.getBlockList and related methods to give clear reasons of why CheckNotNull is included and why this method is only available when blocks are included?
The current method descriptions are not clear enough for users. Thanks for all the investigation!
sure, I will create a PR later
That's the JavaDoc guide that we aim to follow: https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html The Java documentation should be implementation dependent but should be complete, including boundary conditions, parameter ranges and corner cases.
In DefaultBlockStoreMeta.java, we have the following code
The checkNotNull for the two operations which I think does not make sense. In the
DefaultBlockWorkerTest
, I want to add something likewhich doesn't work since the
Preconditions.checkNotNull
. As a user, I would expect an empty list is returned when I get block store metadata when it doesn't have any blocks inside.This task is not asking you to create a PR to remove the
checkNotNull
directly, but a request to ask you to see what's the reasons behind thecheckNotNull
, do they make sense. If they make sense, comment on this issue. If not, change them, make sure nothing breaks and add related unit tests.Time estimate: one to two weeks.