Bug 66425: Avoid a ClassCastException found via oss-fuzz

Add exception details and fix expected exceptions to make tests run again

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911503 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-08-07 11:11:08 +00:00
parent 31fd087a48
commit a8b31c37a6
3 changed files with 2 additions and 2 deletions

View File

@ -286,7 +286,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
} }
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new IllegalArgumentException("Relation and type of document-part did not match, had relation " + relation + " and type of document-part: " + p.getClass()); throw new IllegalArgumentException("Relation and type of document-part did not match, had relation " + relation + " and type of document-part: " + p.getClass(), e);
} }
} }
initHyperlinks(); initHyperlinks();

View File

@ -251,7 +251,7 @@ public final class Chunks implements ChunkGroupWithProperties {
allChunks.computeIfAbsent(prop, k -> new ArrayList<>()); allChunks.computeIfAbsent(prop, k -> new ArrayList<>());
allChunks.get(prop).add(chunk); allChunks.get(prop).add(chunk);
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new IllegalArgumentException("Property and type of chunk did not match, had property " + prop + " and type of chunk: " + chunk.getClass()); throw new IllegalArgumentException("Property and type of chunk did not match, had property " + prop + " and type of chunk: " + chunk.getClass(), e);
} }
} }

Binary file not shown.