Bug 54938: Throw InvalidFormatException as documented instead of IllegalArgumentException in WorkbookFactory.create()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
633eb964b4
commit
0377dbbb3e
@ -208,7 +208,7 @@ public class WorkbookFactory {
|
|||||||
if (POIXMLDocument.hasOOXMLHeader(inp)) {
|
if (POIXMLDocument.hasOOXMLHeader(inp)) {
|
||||||
return new XSSFWorkbook(OPCPackage.open(inp));
|
return new XSSFWorkbook(OPCPackage.open(inp));
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
|
throw new InvalidFormatException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +30,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|||||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||||
import org.apache.poi.util.TempFile;
|
import org.apache.poi.util.TempFile;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -135,7 +136,7 @@ public final class TestWorkbookFactory extends TestCase {
|
|||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
fail();
|
fail();
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(InvalidFormatException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user