Использование набора SVN Невозможно добавить файл в хранилище, и приведенный ниже код вызывает java.lang.NullPointerException - PullRequest
0 голосов
/ 11 января 2012

Я не могу добавить какой-либо файл в хранилище с помощью редактора, он вызывает исключение java.lang.NullPointerException в строке editor.addFile(textfile, null, -1);

try {
    url = "https://XXX.yyy.zzzz";
    SVNRepository repository = null;
    String name = "testuser";
    String password = "testuserpassword";
    repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);
    repository.setAuthenticationManager(authManager);
    System.out.println(repository.getLatestRevision());

    SVNClientInterface client = SVNClientImpl.newInstance();
} catch (Exception e) {
    System.out.println("error");
}               

try { 
    ISVNEditor editor = repository.getCommitEditor("This is a log message.", new CommitMediator()); 

    editor.openRoot(-1); 
    System.out.println("in DAV");
    editor.addFile(textfile, null, -1);
    editor.addFile("file1.txt", null, -1);       
    editor.applyTextDelta("file1.txt", null); 
    OutputStream os=null;
    os.close(); 
    editor.textDeltaEnd(file1.txt); 
    editor.closeFile(file1.txt, null); 
    editor.closeEdit(); 
} catch(Exception e) {
    System.out.println(e);
}

1 Ответ

0 голосов
/ 11 января 2012
editor.addFile(textfile, null, -1);

Что такое textfile?

OutputStream os=null;
os.close();

Возможно, стоит подумать о том, что там происходит.

...