You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2015/07/07 22:18:01 UTC
[Bug 58113] New: calling setCellValue with a null String object
gives null pointer exception
https://bz.apache.org/bugzilla/show_bug.cgi?id=58113
Bug ID: 58113
Summary: calling setCellValue with a null String object gives
null pointer exception
Product: POI
Version: 3.12-FINAL
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: SXSSF
Assignee: dev@poi.apache.org
Reporter: scottd@fluidlife.com
Test code below works fine in version 3.11, gives null pointer exception in
3.12:
Workbook wb = new SXSSFWorkbook();
Sheet sheet = wb.createSheet( "Test" );
Row row = sheet.createRow( 0 );
row.setHeightInPoints( 16.00f );
Cell cell = row.createCell( 0 );
String str = null;
cell.setCellValue( str );
According to the documentation null should be a valid:
"value - value to set the cell to. For formulas we'll set the formula string,
for String cells we'll set its value. For other types we will change the cell
to a string cell and set its value. If value is null then we will change the
cell to a Blank cell."
After downloading the source for 3.11 and 3.12, the problem is pretty clear,
it's now trying to check the length of value without checking if it's null
first.
3.11:
public void setCellValue(String value)
{
ensureTypeOrFormulaType(CELL_TYPE_STRING);
if(_value.getType()==CELL_TYPE_FORMULA)
((StringFormulaValue)_value).setPreEvaluatedValue(value);
else
((PlainStringValue)_value).setValue(value);
}
3.12:
public void setCellValue(String value)
{
ensureTypeOrFormulaType(CELL_TYPE_STRING);
if(value.length() > SpreadsheetVersion.EXCEL2007.getMaxTextLength()){
throw new IllegalArgumentException("The maximum length of cell contents
(text) is 32,767 characters");
}
if(_value.getType()==CELL_TYPE_FORMULA)
((StringFormulaValue)_value).setPreEvaluatedValue(value);
else
((PlainStringValue)_value).setValue(value);
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 58113] calling setCellValue with a null String object gives
null pointer exception
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58113
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
Fixed via r1690652, we now allow null-values again and have unit tests for all
variants (HSSF, XSSF, SXSSF) which verify that it works.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 58113] calling setCellValue with a null String object gives
null pointer exception
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58113
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |regression
OS| |All
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org