mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
24.27.2015 c2d014b947bc2bf09335433af2512e4467a97f50
refs
author Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Friday, April 24, 2015 11:27 +0200
committer Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Friday, April 24, 2015 11:27 +0200
commitc2d014b947bc2bf09335433af2512e4467a97f50
tree 0f0670a0685626f7f7d16b9480c7e9f8aa0aabec tree | zip | gz
parent 7364bd8dff78b48be3ed99d6a466f446218b4b8f view | diff
(CR-6756) Fixed IllegalArgumentException when import triggers index entry limits

IllegalArgumentException was triggered in ImportIDSet.addEntryID() when called with a negative entryID.
The negative entryID was read in IndexInputBuffer.mergeIDSet().
The problem comes from Importer.ScratchFileWriterTask.writeByteStreams() which writes a special value instead of an entryID which means "treat this ImportIDSet has undefined".
First problem, this special value is written as a byte, but read as a long. I fixed the code to write it as a long.
Second problem, the (illogical) code handling this specific case in ImportIDSet.addEntryID() was removed as part of r11948. I fixed this by properly handling this case at a higher level in IndexInputBuffer.mergeIDSet().
I finally applied similar changes to the JE code to explicit what it is doing.



pluggable.ImportIDSet.java:
Changed setUndefined() from private to package private.
Extracted method setUndefinedWithSize().

pluggable.IndexInputBuffer.java:
Added UNDEFINED_SIZE constant.
In mergeIDSet(), handled the undefined size case.
Added toString().

pluggable.Importer.java:
In writeByteStreams(), wrote UNDEFINED_SIZE as a long to the BAOS.
Changed toString() to output the index name.

pluggable.IndexOutputBuffer.java:
Added toString().



Reflected similar changes to JEB. In addition:

jeb.ImportIDSet.java:
In addEntryID(), reject negative entryIDs.

jeb.Importer.java:
In writeByteStreams(), write a packed long (although the encoded representation is the same as packed int, code was conceptually incorrect) + added writePackedLong() method.

jeb.IndexInputBuffer.java:
Extracted readKey().
In mergeIDSet(), handled the undefined size. There is a difference in behaviour: previous the undefined size could be maintained, but now it is no longer maintained: this is correct since there was no count to maintain for an undefined size.
1 files modified
4 ■■■ changed files
opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/SuffixContainer.java 4 ●●● diff | view | raw | blame | history