Skip to content

Commit

Permalink
Avoid NPE when type list is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
takashi-ishio committed May 10, 2021
1 parent f5563e1 commit e81fe80
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/selogger/reader/ObjectTypeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ObjectTypeMap {

private static final int LIST_PER_ITEMS = 128 * 1024 * 1024;

public static final String TYPENAME_NOT_AVAILABLE = "N/A";

//private TLongIntHashMap objectTypeMap;
private ArrayList<int[]> objectTypes;
private TypeList typeList;
Expand Down Expand Up @@ -86,15 +88,23 @@ public int getObjectTypeId(long objectId) {
*/
public String getObjectTypeName(long objectId) {
int typeId = getObjectTypeId(objectId);
return typeList.getType(typeId);
if (typeList != null) {
return typeList.getType(typeId);
} else {
return TYPENAME_NOT_AVAILABLE;
}
}

/**
* @param specifies a type ID.
* @return type name for the specified type ID.
*/
public String getTypeName(int typeId) {
return typeList.getType(typeId);
if (typeList != null) {
return typeList.getType(typeId);
} else {
return TYPENAME_NOT_AVAILABLE;
}
}

}

0 comments on commit e81fe80

Please sign in to comment.