Skip to content

Commit

Permalink
Fix disk serialization of lists of embedded maps with null values
Browse files Browse the repository at this point in the history
Resolves: #8531
  • Loading branch information
luigidellaquila committed Sep 13, 2018
1 parent 0327321 commit f2e2240
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ protected int writeEmbeddedMap(BytesContainer bytes, Map<Object, Object> map) {
writeOType(bytes, (pos[i] + OIntegerSerializer.INT_SIZE), type);
} else {
//signal for null value
writeEmptyString(bytes);
OIntegerSerializer.INSTANCE.serializeLiteral(0, bytes.bytes, pos[i]);
}
}
return fullPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerNetwork;
import com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerNetworkV37;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.math.BigDecimal;
import java.util.*;

import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class ODocumentSchemalessBinarySerializationTest {
Expand Down Expand Up @@ -952,6 +952,31 @@ public void testPartialNotFound() {
}
}

@Test
public void testListOfMapsWithNull(){
ODatabaseRecordThreadLocal.instance().remove();
ODocument document = new ODocument();


List lista = new ArrayList<>();
Map mappa = new LinkedHashMap<>();
mappa.put("prop1", "val1");
mappa.put("prop2", null);
lista.add(mappa);

mappa = new HashMap();
mappa.put("prop", "val");
lista.add(mappa);
document.setProperty("list", lista);


byte[] res = serializer.toStream(document, false);
ODocument extr = (ODocument) serializer.fromStream(res, new ODocument(), new String[] {});
assertEquals(extr.fields(), document.fields());
assertEquals(extr.<Object>field("list"), document.field("list"));
}


public static class Custom implements OSerializableStream {
byte[] bytes = new byte[10];

Expand Down

0 comments on commit f2e2240

Please sign in to comment.