#vulnerable code 
                                @Test
    public void testReplaceUsers(){
        List<ReadUser> allUsers = Users.defaultUsers().list();

        File tmpDir = Files.createTempDir();
        File users = new File(tmpDir, "users.csv");

        try {
            PrintWriter userPrintWriter = new PrintWriter(new BufferedWriter(new FileWriter(users, false)));
            userPrintWriter.append("姓名,帐号,微信号,手机号,邮箱,所在部门,职位").append("\n");

            for(ReadUser user: allUsers) {
                CreateUser createUser = new CreateUser();
                createUser.setName(user.getName());
                createUser.setMobile(user.getMobile());
                createUser.setUserId(user.getUserId());
                createUser.setPosition(user.getPosition());
                createUser.setWeixinId(user.getWeixinId());
                createUser.setDepartment(user.getDepartment());
                createUser.setEmail(user.getEmail());
                userPrintWriter.append(csv(createUser));
            }

            userPrintWriter.close();

            String job = Jobs.defaultJobs().replaceUsers(users);
            while (true) {
                JobResult jobResult = Jobs.defaultJobs().getResult(job);
                if (3 == jobResult.getStatus()) {
                    if (100 == jobResult.getPercentage()) {
                        Assert.assertTrue(true);
                    }
                    break;
                } else {
                    System.out.println("正在同步:" + jobResult.getPercentage());
                    sleep(10);
                }
            }
        } catch(Exception e) {
            e.printStackTrace();
            Assert.fail("test failed.");
        } finally {
            try {
                FileUtils.forceDelete(tmpDir);
            } catch (IOException e) {
            }
        }
    } 
                            #location 39 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void testReplaceUsers(){
        List<ReadUser> allUsers = Users.defaultUsers().list();

        File tmpDir = Files.createTempDir();
        File users = new File(tmpDir, "users.csv");

        try {
            PrintWriter userPrintWriter = new PrintWriter(new BufferedWriter(new FileWriter(users, false)));
            userPrintWriter.println("姓名,帐号,微信号,手机号,邮箱,所在部门,职位");

            for(ReadUser user: allUsers) {
                CreateUser createUser = new CreateUser();
                createUser.setName(user.getName());
                createUser.setMobile(user.getMobile());
                createUser.setUserId(user.getUserId());
                createUser.setPosition(user.getPosition());
                createUser.setWeixinId(user.getWeixinId());
                createUser.setDepartment(user.getDepartment());
                createUser.setEmail(user.getEmail());
                userPrintWriter.print(csv(createUser));
            }

            userPrintWriter.close();

            String job = Jobs.defaultJobs().replaceUsers(users);
            while (true) {
                JobResult jobResult = Jobs.defaultJobs().getResult(job);
                if (3 == jobResult.getStatus()) {
                    if (100 == jobResult.getPercentage()) {
                        Assert.assertTrue(true);
                    }
                    break;
                } else {
                    System.out.println("正在同步:" + jobResult.getPercentage());
                    sleep(10);
                }
            }
        } catch(Exception e) {
            e.printStackTrace();
            Assert.fail("test failed.");
        } finally {
            try {
                FileUtils.forceDelete(tmpDir);
            } catch (IOException e) {
            }
        }
    }