summaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2018-06-02 20:29:35 +0000
committerAndreas Beeker <kiwiwings@apache.org>2018-06-02 20:29:35 +0000
commit9eb37895093051dc75b0ce52843d7e717cf31aea (patch)
treea0d44eed136767aa9f54fc7c9dc3f8ce8b0efd54 /src/scratchpad
parent87f7eac9c56c5a1e33a5309e4af64da178db61e7 (diff)
downloadpoi-9eb37895093051dc75b0ce52843d7e717cf31aea.tar.gz
poi-9eb37895093051dc75b0ce52843d7e717cf31aea.zip
sonar fixes and
disable closing of outputstream in ZipPackage.saveImpl() - see https://stackoverflow.com/questions/50646538/stream-close-exception-occures git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1832746 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java13
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java13
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java11
3 files changed, 16 insertions, 21 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
index 29576c5542..ad51d4b7cf 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
@@ -95,12 +96,12 @@ public class WordToFoConverter extends AbstractWordConverter
static Document process( File docFile ) throws Exception
{
- final HWPFDocumentCore hwpfDocument = WordToFoUtils.loadDoc( docFile );
- WordToFoConverter wordToFoConverter = new WordToFoConverter(
- XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
- .newDocument() );
- wordToFoConverter.processDocument( hwpfDocument );
- return wordToFoConverter.getDocument();
+ final DocumentBuilder docBuild = XMLHelper.getDocumentBuilderFactory().newDocumentBuilder();
+ try (final HWPFDocumentCore hwpfDocument = WordToFoUtils.loadDoc( docFile )) {
+ WordToFoConverter wordToFoConverter = new WordToFoConverter(docBuild.newDocument());
+ wordToFoConverter.processDocument(hwpfDocument);
+ return wordToFoConverter.getDocument();
+ }
}
private List<Element> endnotes = new ArrayList<>(0);
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
index 6a9cd82fe0..42fe7fd30d 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
@@ -24,6 +24,7 @@ import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
@@ -163,12 +164,12 @@ public class WordToHtmlConverter extends AbstractWordConverter
static Document process( File docFile ) throws IOException, ParserConfigurationException
{
- final HWPFDocumentCore wordDocument = AbstractWordUtils.loadDoc( docFile );
- WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(
- XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
- .newDocument() );
- wordToHtmlConverter.processDocument( wordDocument );
- return wordToHtmlConverter.getDocument();
+ final DocumentBuilder docBuild = XMLHelper.getDocumentBuilderFactory().newDocumentBuilder();
+ try (final HWPFDocumentCore wordDocument = AbstractWordUtils.loadDoc( docFile )) {
+ WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(docBuild.newDocument());
+ wordToHtmlConverter.processDocument(wordDocument);
+ return wordToHtmlConverter.getDocument();
+ }
}
@Override
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java b/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java
index e859ad5c6c..8eec2af3fe 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java
@@ -79,22 +79,15 @@ public final class HWPFLister
{
private static HWPFDocumentCore loadDoc( File docFile ) throws IOException
{
- final FileInputStream istream = new FileInputStream( docFile );
- try
- {
+ try (final FileInputStream istream = new FileInputStream( docFile )) {
return loadDoc( istream );
}
- finally
- {
- IOUtils.closeQuietly( istream );
- }
}
private static HWPFDocumentCore loadDoc( InputStream inputStream )
throws IOException
{
- final POIFSFileSystem poifsFileSystem = HWPFDocumentCore
- .verifyAndBuildPOIFS( inputStream );
+ final POIFSFileSystem poifsFileSystem = HWPFDocumentCore.verifyAndBuildPOIFS( inputStream );
try
{
return new HWPFDocument( poifsFileSystem );