Bugzilla 52062: ensure that temporary files in SXSSF are deleted
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1198693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21b4a0f948
commit
e021457005
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.8-beta5" date="2011-??-??">
|
||||
<action dev="poi-developers" type="fix">52062 - ensure that temporary files in SXSSF are deleted</action>
|
||||
<action dev="poi-developers" type="fix">50936 - Exception parsing MS Word 8.0 file (as duplicate of 47958)</action>
|
||||
<action dev="poi-developers" type="fix">47958 - ArrayIndexOutOfBoundsException from PicturesTable.getAllPictures() during Escher tree walk</action>
|
||||
<action dev="poi-developers" type="fix">51944 - PAPFormattedDiskPage.getPAPX - IndexOutOfBounds</action>
|
||||
|
@ -1284,7 +1284,7 @@ public class SXSSFSheet implements Sheet, Cloneable
|
||||
|
||||
public SheetDataWriter() throws IOException
|
||||
{
|
||||
_fd = File.createTempFile("poi-sxxsf-sheet", ".xml");
|
||||
_fd = File.createTempFile("poi-sxssf-sheet", ".xml");
|
||||
_fd.deleteOnExit();
|
||||
_out = new BufferedWriter(new FileWriter(_fd));
|
||||
}
|
||||
|
@ -186,9 +186,11 @@ public class SXSSFWorkbook implements Workbook
|
||||
private void injectData(File zipfile, OutputStream out) throws IOException
|
||||
{
|
||||
ZipFile zip = new ZipFile(zipfile);
|
||||
|
||||
try
|
||||
{
|
||||
ZipOutputStream zos = new ZipOutputStream(out);
|
||||
|
||||
try
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
|
||||
while (en.hasMoreElements())
|
||||
@ -200,7 +202,15 @@ public class SXSSFWorkbook implements Workbook
|
||||
if(xSheet!=null)
|
||||
{
|
||||
SXSSFSheet sxSheet=getSXSSFSheet(xSheet);
|
||||
copyStreamAndInjectWorksheet(is,zos,sxSheet.getWorksheetXMLInputStream());
|
||||
InputStream xis = sxSheet.getWorksheetXMLInputStream();
|
||||
try
|
||||
{
|
||||
copyStreamAndInjectWorksheet(is,zos,xis);
|
||||
}
|
||||
finally
|
||||
{
|
||||
xis.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -208,9 +218,17 @@ public class SXSSFWorkbook implements Workbook
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
zos.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
zip.close();
|
||||
}
|
||||
}
|
||||
private static void copyStream(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] chunk = new byte[1024];
|
||||
int count;
|
||||
@ -649,7 +667,7 @@ public class SXSSFWorkbook implements Workbook
|
||||
}
|
||||
|
||||
//Save the template
|
||||
File tmplFile = File.createTempFile("poi-sxxsf-template", ".xlsx");
|
||||
File tmplFile = File.createTempFile("poi-sxssf-template", ".xlsx");
|
||||
tmplFile.deleteOnExit();
|
||||
FileOutputStream os = new FileOutputStream(tmplFile);
|
||||
_wb.write(os);
|
||||
|
Loading…
Reference in New Issue
Block a user