Bug 37058

Summary: Sheet.getProtect() generates an exception
Product: POI Reporter: Bill Seddon <bill.seddon>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major CC: huri
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: All   
OS: Windows XP   

Description Bill Seddon 2005-10-12 21:03:30 UTC
Variable "protected" in class Sheet can be null when HSSFSheet.isProtected() 
is called.  Because there is no error detection around this call stack, an 
error can be generated.

A resolution is is to add the line

if (protect == null) protect = (ProtectRecord)createProtect();

before the return statement in Sheet.isProtected() though I don't know if this 
is valid.
Comment 1 Jason Height 2006-01-13 03:21:37 UTC
HSSFSheet.getProtected is the call.

Sheet.getProtected (which returns the ProtectedRecord) will now create and add
the ProtectedRecord to the list of records for the Sheet.

Committed in SVN.

Jason
Comment 2 Josh Micich 2008-05-10 19:52:56 UTC
*** Bug 27749 has been marked as a duplicate of this bug. ***
Comment 3 Josh Micich 2009-06-15 13:09:38 UTC
Original fix was in svn r368554


Follow-up info:

Original test code (from bug 27749) is no longer valid:

    HSSFSheet sheet = workBook.cloneSheet(index);
    sheet.setProtect(true);


The method HSSFSheet.setProtect(boolean) was deprecated (svn r552425 ) because it didn't set a password hash.  As of the fix for bug 47363 (svn r784240 ), the deprecated method was removed.

The test code for this problem would now look like this:

    HSSFSheet sheet = workBook.cloneSheet(index);
    sheet.protectSheet("secret");

This still works OK in svn trunk