ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Bug 60767] New: NPE during unit testing of GenerateKey.DistinguishedName class
Date Wed, 22 Feb 2017 16:06:05 GMT

            Bug ID: 60767
           Summary: NPE during unit testing of
                    GenerateKey.DistinguishedName class
           Product: Ant
           Version: nightly
          Hardware: Macintosh
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
  Target Milestone: ---

I get an NPE during unit testing of GenerateKey.DistinguishedName class. 

public void test() throws Throwable {
  DistinguishedName name = new DistinguishedName();

Call Stack$DistinguishedName.encode($DistinguishedName.toString(

public String toString() {
  final int size = params.size();
  final StringBuffer sb = new StringBuffer();
  boolean firstPass = true;

  for (int i = 0; i < size; i++) {
    if (!firstPass) {
      sb.append(" ,");
    firstPass = false;

    final DnameParam param = (DnameParam) params.elementAt(i);
    sb.append(encode(param.getName())); // line 122 

  return sb.toString();

public String encode(final String string) {
  int end = string.indexOf(','); // line 138 - NPE because string is null

At line 138, NPE occurs because DnameParam object (param) created in
createParam() does not set its fields properly. So, param.getName() in
toString() returns null and passed as an argument of encode(...).
To avoid a crash, I think either createParam() should set its fields with
default values at least, or a null-checker should be added in toString or
encode methods.

You are receiving this mail because:
You are the assignee for the bug.
View raw message