CPD Results

The following document contains the results of PMD's CPD 4.1.

Duplications

File Line
com\gridsystems\innergrid\api\AbstractImplBase.java 289
com\gridsystems\innergrid\api\ClientApiProxy.java 237
  }

  /**
   * Provides a CKernelException with the info of a deserialization error.
   *
   * Provides a CKernelException with the info of a deserialization error. It
   * will try to parse the error message to find the parameters for the
   * exception message.
   *
   * @param axisFault the AxisFault original.
   *
   * @return a CKernelException with more accurate data of the error that has
   * happened.
   */
  private CKernelException getDeserializationException(AxisFault axisFault) {
    // Number of resulting groups for a valid matching
    // This definition prevents several CheckStyle warnings
    final int groupCount = 3;

    Pattern pat = Pattern.compile("'in(\\d+).+http\\:\\/\\/([\\w\\.]*)}(\\w+)$");
    Matcher mat = pat.matcher(axisFault.getFaultString());
    String[] params = new String[2];
    if (mat.find() && (mat.groupCount() == groupCount)) {
      params[0] = mat.group(1);
      // The string provides the package name in reverse form (as an URL). Here
      // we put it back in its original state.
      String packageName = namespaceToClass(mat.group(2), mat.group(groupCount));
      params[1] = packageName + mat.group(groupCount);
    } else {
      params[0] = "?";
      params[1] = "?";
    }
    return new CKernelException(axisFault, "CLT005", params);
  }

  /**
   * Converts a namespace and local name to a class name. The local name is the
   * unqualified class name. The namespace is the class package name in reverse order.
   *
   * @param namespace  The namespace
   * @param localName  The local name
   * @return The associated class name
   */
  private String namespaceToClass(String namespace, String localName) {
    StringBuffer sb = new StringBuffer(localName);
    for (StringTokenizer st = new StringTokenizer(namespace, "."); st.hasMoreTokens();) {
      sb.insert(0, ".");
      sb.insert(0, st.nextToken());
    }
    return sb.toString();
  }

File Line
com\gridsystems\innergrid\kernel\KernelException.java 396
com\gridsystems\innergrid\kernel\KernelException.java 425
  @Override public void printStackTrace(PrintStream out) {
    synchronized (out) {
      out.println(this.getCode() + ": " + this.getMessage());

      Throwable cause = this.getCause();
      if (cause != null) {
        out.println("Caused By:");
        out.println(cause.toString());
      } else {
        cause = this;
      }
      StackTraceElement[] trace = cause.getStackTrace();
      int count = trace == null ? 0 : trace.length;
      int max = traceLength(trace);
      for (int i = 0; i < max; i++) {
        out.println("\tat " + trace[i]);
      }
      if (max < count) {
        out.println("\tat " + trace[max]);
        out.println("\t... [" + (count - max - 1) + " elements omitted]");
      }
    }
  }

File Line
com\gridsystems\innergrid\api\AbstractImplBase.java 247
com\gridsystems\innergrid\api\ClientApiProxy.java 195
        String port = String.valueOf(this.con.getPort());

        // Client Exception
        if (cause instanceof ConnectException) {
          //  -- Host exists but the port is not open
          return new CKernelException(e, "CLT001", port, host);
        } else if (cause instanceof UnknownHostException) {
          //  -- Cannot found server
          return new CKernelException(e, "CLT000", host);
        } else if (cause instanceof SocketException) {
          // -- Connection closed by server
          return new CKernelException(e, "CLT002", host);
        }
      }
      if (af.getFaultCode().getLocalPart().equals("Server.NoService")) {

        String reason = af.getFaultReason();
        String apiname = "?";
        if (reason != null) {
          int pos = reason.lastIndexOf(' ');
          if (pos != -1) {
            apiname = reason.substring(pos + 1);

File Line
com\gridsystems\innergrid\api\AbstractImplBase.java 268
com\gridsystems\innergrid\api\ClientApiProxy.java 216
            apiname = reason.substring(pos + 1);
          }
        }
        return new CKernelException(e, "CLT003", apiname);
      } else if (af.getFaultCode().getLocalPart().equals("CLT004")) {
        return new CKernelException(e, "CLT004", e.getMessage());
      } else if (af.getFaultString().indexOf(
        "could not find deserializer for type") != -1) {
        return getDeserializationException(af);
      } else if (af.getFaultString().startsWith("(404)/kernel/api")) {
        return new CKernelException("CLT006");
      }
    }

    if (e instanceof RemoteException) {
      RemoteException re = (RemoteException) e;
      return KernelException.fromRemoteException(re);
    } else {