Bugzilla >53974 - Avoid exception when constructing HSSFWorbook on Google App Engine

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1396543 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2012-10-10 11:09:48 +00:00
parent eb40f810d5
commit 299ca1472b
2 changed files with 8 additions and 2 deletions

View File

@ -34,6 +34,7 @@
<changes> <changes>
<release version="3.9-beta1" date="2012-??-??"> <release version="3.9-beta1" date="2012-??-??">
<action dev="poi-developers" type="fix">53974 - Avoid NPE when constructing HSSFWorbook on Google App Engine</action>
<action dev="poi-developers" type="fix">53568 - Fixed null returned by XSSFPicture.getPictureData()</action> <action dev="poi-developers" type="fix">53568 - Fixed null returned by XSSFPicture.getPictureData()</action>
<action dev="poi-developers" type="fix">53950 - fixed setForceFormulaRecalculation to reset workbook-level "manual" flag</action> <action dev="poi-developers" type="fix">53950 - fixed setForceFormulaRecalculation to reset workbook-level "manual" flag</action>
<action dev="poi-developers" type="fix">52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause exceptions on ibm mainframes</action> <action dev="poi-developers" type="fix">52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause exceptions on ibm mainframes</action>

View File

@ -1094,12 +1094,17 @@ public final class InternalWorkbook {
private static WriteAccessRecord createWriteAccess() { private static WriteAccessRecord createWriteAccess() {
WriteAccessRecord retval = new WriteAccessRecord(); WriteAccessRecord retval = new WriteAccessRecord();
String defaultUserName = "POI";
try { try {
retval.setUsername(System.getProperty("user.name")); String username = System.getProperty("user.name");
// Google App engine returns null for user.name, see Bug 53974
if(username == null) username = defaultUserName;
retval.setUsername(username);
} catch (AccessControlException e) { } catch (AccessControlException e) {
// AccessControlException can occur in a restricted context // AccessControlException can occur in a restricted context
// (client applet/jws application or restricted security server) // (client applet/jws application or restricted security server)
retval.setUsername("POI"); retval.setUsername(defaultUserName);
} }
return retval; return retval;
} }