remove deprecated hasOOXMLHeader method (#941)

This commit is contained in:
PJ Fanning 2025-11-19 13:58:41 +01:00 committed by GitHub
parent 9fb2c4b03e
commit 540f0e5617
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 24 deletions

View File

@ -54,10 +54,6 @@ class TestDetectAsOOXML {
void testDetectAsPOIFS(String file, FileMagic fm) throws IOException {
try (InputStream is = FileMagic.prepareToCheckMagic(openSampleFileStream(file))) {
FileMagic act = FileMagic.valueOf(is);
assertEquals(act == FileMagic.OOXML, DocumentFactoryHelper.hasOOXMLHeader(is),
"OOXML files should be detected, others not");
assertEquals(fm, act, "file magic failed for " + file);
}
}
@ -70,7 +66,7 @@ class TestDetectAsOOXML {
InputStream is = FileMagic.prepareToCheckMagic(testInput);
// detect header
assertFalse(DocumentFactoryHelper.hasOOXMLHeader(is));
assertFalse(FileMagic.valueOf(is) == FileMagic.OOXML);
// check if InputStream is still intact
byte[] act = IOUtils.toByteArray(is);

View File

@ -28,7 +28,6 @@ import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.crypt.Decryptor;
import org.apache.poi.poifs.crypt.EncryptionInfo;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
/**
* A small base class for the various factories, e.g. WorkbookFactory,
@ -100,22 +99,4 @@ public final class DocumentFactoryHelper {
throw new IOException(e);
}
}
/**
* Checks that the supplied InputStream (which MUST
* support mark and reset) has a OOXML (zip) header at the start of it.<p>
*
* If unsure if your InputStream does support mark / reset,
* use {@link FileMagic#prepareToCheckMagic(InputStream)} to wrap it and make
* sure to always use that, and not the original!
*
* @param inp An InputStream which supports either mark/reset
*
* @deprecated in 3.17-beta2, use {@link FileMagic#valueOf(InputStream)} == FileMagic.OOXML instead
*/
@Deprecated
@Removal(version="4.0")
public static boolean hasOOXMLHeader(InputStream inp) throws IOException {
return FileMagic.valueOf(inp) == FileMagic.OOXML;
}
}