This is an automated email from the ASF dual-hosted git repository.

garyw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mnemonic.git


The following commit(s) were added to refs/heads/master by this push:
     new 365a9dd  MNEMONIC-737: Unchecked null may cause NULLException in 
JavaVMemServiceImpl
365a9dd is described below

commit 365a9dd5680ab659389d49621801bb2d79fc4d3e
Author: Li Shen <[email protected]>
AuthorDate: Thu Mar 24 21:08:29 2022 -0700

    MNEMONIC-737: Unchecked null may cause NULLException in JavaVMemServiceImpl
---
 .../mnemonic/service/memory/internal/JavaVMemServiceImpl.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/mnemonic-memory-services/mnemonic-java-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/JavaVMemServiceImpl.java
 
b/mnemonic-memory-services/mnemonic-java-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/JavaVMemServiceImpl.java
index 78d3e78..717216d 100644
--- 
a/mnemonic-memory-services/mnemonic-java-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/JavaVMemServiceImpl.java
+++ 
b/mnemonic-memory-services/mnemonic-java-vmem-service/src/main/java/org/apache/mnemonic/service/memory/internal/JavaVMemServiceImpl.java
@@ -191,7 +191,10 @@ public class JavaVMemServiceImpl implements 
VolatileMemoryAllocatorService {
           }
         }
         markUsed(chunksMap, startIdx, requiredBlocks);
-        mi.getByteBufferBlocksList().get(blockIdx).setChunkSizeMap(handler, 
bufSize);
+        BufferBlockInfo bufferBlock = 
mi.getByteBufferBlocksList().get(blockIdx)
+        if (bufferBlock != null) {
+          bufferBlock.setChunkSizeMap(handler, bufSize);
+        }
         break;
       }
     }
@@ -288,7 +291,7 @@ public class JavaVMemServiceImpl implements 
VolatileMemoryAllocatorService {
       handler = getByteBufferHandler(id, bytebuf);
       for (int blockIdx = 0; blockIdx < mi.getByteBufferBlocksList().size(); 
blockIdx++) {
         BufferBlockInfo bufferBlock = 
mi.getByteBufferBlocksList().get(blockIdx);
-        if (bufferBlock.getChunkSizeMap().containsKey(handler)) {
+        if (bufferBlock != null && 
bufferBlock.getChunkSizeMap().containsKey(handler)) {
           BitSet chunksMap = bufferBlock.getBufferBlockChunksMap();
           baseAddr = bufferBlock.getBufferBlockBaseAddress();
           startIdx = (int)Math.floor((double)((handler - baseAddr) / 
CHUNK_BLOCK_SIZE));
@@ -309,7 +312,7 @@ public class JavaVMemServiceImpl implements 
VolatileMemoryAllocatorService {
     int size;
     for (int blockIdx = 0; blockIdx < mi.getByteBufferBlocksList().size(); 
blockIdx++) {
       BufferBlockInfo blockInfo = mi.getByteBufferBlocksList().get(blockIdx);
-      if (blockInfo.getChunkSizeMap().containsKey(handler)) {
+      if (blockInfo != null && 
blockInfo.getChunkSizeMap().containsKey(handler)) {
         size = blockInfo.getChunkSizeMap().get(handler);
         bb = createChunkBuffer(handler, size);
       }
@@ -324,7 +327,7 @@ public class JavaVMemServiceImpl implements 
VolatileMemoryAllocatorService {
     MemoryInfo mi = this.getMemPools().get((int)id);
     for (int blockIdx = 0; blockIdx < mi.getByteBufferBlocksList().size(); 
blockIdx++) {
       BufferBlockInfo blockInfo = mi.getByteBufferBlocksList().get(blockIdx);
-      if (blockInfo.getChunkSizeMap().containsKey(handler)) {
+      if (blockInfo != null && 
blockInfo.getChunkSizeMap().containsKey(handler)) {
         size = blockInfo.getChunkSizeMap().get(handler);
       }
     }

Reply via email to