Author: centic
Date: Sat Oct 7 22:12:58 2023
New Revision: 1912799
URL: http://svn.apache.org/viewvc?rev=1912799&view=rev
Log:
Bug 66425: Avoid exceptions found via poi-fuzz
Fix check after commit fcaac5073716b98cba26c0655f06f20e310fd85e
so that other IndexOutOfBoundsExceptions are still thrown out
Also free resources when throwing an exception in the constructor
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1912799&r1=1912798&r2=1912799&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
Sat Oct 7 22:12:58 2023
@@ -63,8 +63,16 @@ public class SXSSFSheet implements Sheet
setRandomAccessWindowSize(randomAccessWindowSize);
try {
_autoSizeColumnTracker = new AutoSizeColumnTracker(this);
- } catch (UnsatisfiedLinkError | InternalError e) {
- LOG.atWarn().log("Failed to create AutoSizeColumnTracker, possibly
due to fonts not being installed in your OS", e);
+ } catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError |
+ // thrown when no fonts are available in the workbook
+ IndexOutOfBoundsException e) {
+ // only handle special NoClassDefFound
+ if (!e.getMessage().contains("X11FontManager")) {
+ throw e;
+ }
+ LOG.atWarn()
+ .withThrowable(e)
+ .log("Failed to create AutoSizeColumnTracker, possibly due
to fonts not being installed in your OS");
}
}
@@ -99,9 +107,21 @@ public class SXSSFSheet implements Sheet
} catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError |
// thrown when no fonts are available in the workbook
IndexOutOfBoundsException e) {
+ // only handle special NoClassDefFound
+ if (!e.getMessage().contains("X11FontManager")) {
+ // close temporary resources when throwing exception in the
constructor
+ _writer.close();
+
+ throw e;
+ }
LOG.atWarn()
.withThrowable(e)
.log("Failed to create AutoSizeColumnTracker, possibly due
to fonts not being installed in your OS");
+ } catch (Throwable e) {
+ // close temporary resources when throwing exception in the
constructor
+ _writer.close();
+
+ throw e;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]