Bug 37058 - Sheet.getProtect() generates an exception
Summary: Sheet.getProtect() generates an exception
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: All Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 27749 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-12 21:03 UTC by Bill Seddon
Modified: 2009-06-15 13:09 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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