Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in WriteBufferManager.addRecord #296

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.reflect.ClassTag$;
import scala.reflect.ManifestFactory$;

import org.apache.uniffle.client.util.ClientUtils;
import org.apache.uniffle.common.ShuffleBlockInfo;
Expand Down Expand Up @@ -112,7 +113,11 @@ public List<ShuffleBlockInfo> addRecord(int partitionId, Object key, Object valu
final long start = System.currentTimeMillis();
arrayOutputStream.reset();
serializeStream.writeKey(key, ClassTag$.MODULE$.apply(key.getClass()));
serializeStream.writeValue(value, ClassTag$.MODULE$.apply(value.getClass()));
if (value != null) {
serializeStream.writeValue(value, ClassTag$.MODULE$.apply(value.getClass()));
} else {
serializeStream.writeValue(null, ManifestFactory$.MODULE$.Null());
}
serializeStream.flush();
serializeTime += System.currentTimeMillis() - start;
byte[] serializedData = arrayOutputStream.getBuf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ public void addHugeRecordTest() {
assertEquals(1, wbm.getBuffers().size());
}

@Test
public void addNullValueRecordTest() {
SparkConf conf = getConf();
WriteBufferManager wbm = createManager(conf);
String testKey = "key";
String testValue = null;
List<ShuffleBlockInfo> result = wbm.addRecord(0, testKey, testValue);
assertEquals(0, result.size());
assertEquals(512, wbm.getAllocatedBytes());
assertEquals(32, wbm.getUsedBytes());
assertEquals(0, wbm.getInSendListBytes());
assertEquals(1, wbm.getBuffers().size());
}

@Test
public void createBlockIdTest() {
SparkConf conf = getConf();
Expand Down