diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
index 241d06f63d..8d3d57ef8b 100644
--- a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
+++ b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
@@ -193,7 +193,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
* @return index the index of added entry
* @deprecated use addSharedStringItem(RichTextString string)
instead
*/
- @Removal(version = "4.2")
+ @Removal(version = "4.2") //make private in 4.2
public int addEntry(CTRst st) {
String s = getKey(st);
count++;
@@ -278,8 +278,8 @@ public class SharedStringsTable extends POIXMLDocumentPart {
@Override
protected void commit() throws IOException {
PackagePart part = getPackagePart();
- OutputStream out = part.getOutputStream();
- writeTo(out);
- out.close();
+ try (OutputStream out = part.getOutputStream()) {
+ writeTo(out);
+ }
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
index cae2aee0d1..f47c93ebf1 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
@@ -280,7 +280,7 @@ public class SheetDataWriter implements Closeable {
case STRING: {
if (_sharedStringSource != null) {
XSSFRichTextString rt = new XSSFRichTextString(cell.getStringCellValue());
- int sRef = _sharedStringSource.addEntry(rt.getCTRst());
+ int sRef = _sharedStringSource.addSharedStringItem(rt);
writeAttribute("t", STCellType.S.toString());
_out.write(">");