代码注释行引发异常

时间:2019-03-28 18:46:46

标签: java spring

我抛出了一个完全合乎逻辑的异常:我创建了一个工作簿,然后尝试在创建工作表之前调用getSheetAt(0)。令人费解的是,我注释掉了这段代码,但是在注释的同一行代码上却收到了非法参数异常。它甚至指向堆栈跟踪中的这一行代码,这怎么可能?当我在代码堆栈中复制时,溢出甚至都没有将其读取为代码!

我尝试保存所有文件,停止然后清理我的服务器,然后使用加载的最新项目备份它。此文件称为FileUploadController,正在读取第40行,如下所示:

    //  XSSFSheet outputSheet = outputBook.getSheetAt(0);

    @ResponseBody
    @RequestMapping(value = "/uploadMultipleFile", method = RequestMethod.POST)
    public String uploadMultipleFileHandler(@RequestParam("CFfile") MultipartFile file) throws IOException {
        File outputFile = null;

//      XSSFWorkbook outputBook = new XSSFWorkbook();
//      XSSFSheet outputSheet = outputBook.getSheetAt(0);
//      XSSFRow outRow;
//      XSSFCell outCell;
//      DataFormatter formatter = new DataFormatter();

        System.out.println("calling upload multiple file handler");
        System.out.println("file size: " + file.getSize());
        System.out.println("file content type: " + file.getContentType());
        System.out.println("file name " + file.getOriginalFilename());
        System.out.println("file is there? : " + file.isEmpty());

Expected: Sysout statements are read

Actual: 
SEVERE: Servlet.service() for servlet [spring-dispatcher] in context with path [/XDE_V1.2] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Sheet index (0) is out of range (0..-1)] with root cause
java.lang.IllegalArgumentException: Sheet index (0) is out of range (0..-1)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.validateSheetIndex(XSSFWorkbook.java:1043)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.getSheetAt(XSSFWorkbook.java:834)
    at com.cognizant.idw.xde.controllers.FileUploadController.uploadMultipleFileHandler(FileUploadController.java:40)

0 个答案:

没有答案