Skip to content

Commit

Permalink
JENKINS-51817 fix NPEs (#219)
Browse files Browse the repository at this point in the history
* JENKINS-51817 fix NPEs

* JENKINS-51817 make sure message is not null
  • Loading branch information
BerndFarkaDyna authored and kuisathaverat committed Jun 10, 2018
1 parent c56204a commit d6d6528
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Expand Up @@ -36,18 +36,18 @@
public class RemotableSVNErrorMessage extends SVNErrorMessage {

public RemotableSVNErrorMessage(SVNErrorCode code) {
super(code, null, null, null, 0);
super(code, "", new Object[]{}, null, 0);
}

public RemotableSVNErrorMessage(SVNErrorCode code, String message) {
super(code, message, null, null, 0);
super(code, message == null ? "" : message, new Object[]{}, null, 0);
}

public RemotableSVNErrorMessage(SVNErrorCode code, Throwable cause) {
super(code, null, null, new ProxyException(cause), 0);
super(code, "", new Object[]{}, new ProxyException(cause), 0);
}

public RemotableSVNErrorMessage(SVNErrorCode code, String message, Throwable cause) {
super(code, message, null, new ProxyException(cause), 0);
super(code, message == null ? "" : message, new Object[]{}, new ProxyException(cause), 0);
}
}
@@ -0,0 +1,19 @@
package jenkins.scm.impl.subversion;

import org.junit.Assert;
import org.junit.Test;
import org.tmatesoft.svn.core.SVNErrorCode;

import static org.junit.Assert.assertNotNull;

public class RemotableSVNErrorMessageTest {

@Test
public void shouldNotThrowNPEsInToString() {
assertNotNull(new RemotableSVNErrorMessage(SVNErrorCode.APMOD_CONNECTION_ABORTED).toString());
assertNotNull(new RemotableSVNErrorMessage(SVNErrorCode.APMOD_CONNECTION_ABORTED, "message").toString());
assertNotNull(new RemotableSVNErrorMessage(SVNErrorCode.APMOD_CONNECTION_ABORTED, new Exception()).toString());
assertNotNull(new RemotableSVNErrorMessage(SVNErrorCode.APMOD_CONNECTION_ABORTED, "message", new Exception()).toString());
}

}

0 comments on commit d6d6528

Please sign in to comment.