CPD Results

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

Duplications

FileLine
org\apache\maven\surefire\util\NestedCheckedException.java116
org\apache\maven\surefire\util\NestedRuntimeException.java116
    public NestedRuntimeException( Throwable ex )
    {
        super();
        this.cause = ex;
    }

    /**
     * Return the nested cause, or <code>null</code> if none.
     * <p>Note that this will only check one level of nesting.
     * Use <code>getRootCause()</code> to retrieve the innermost cause.
     *
     * @see #getRootCause()
     */
    public Throwable getCause()
    {
        // Even if you cannot set the cause of this exception other than through
        // the constructor, we check for the cause being "this" here, as the cause
        // could still be set to "this" via reflection: for example, by a remoting
        // deserializer like Hessian's.
        return ( this.cause == this ? null : this.cause );
    }

    /**
     * Return the detail message, including the message from the nested exception
     * if there is one.
     */
    public String getMessage()
    {
        if ( getCause() == null )
        {
            return super.getMessage();
        }
        else
        {
            return super.getMessage() + "; nested exception is " + getCause().getClass().getName() + ": " +
                getCause().getMessage();
        }
    }

    /**
     * Print the composite message and the embedded stack trace to the specified stream.
     *
     * @param ps the print stream
     */
    public void printStackTrace( PrintStream ps )
    {
        if ( getCause() == null )
        {
            super.printStackTrace( ps );
        }
        else
        {
            ps.println( this );
            getCause().printStackTrace( ps );
        }
    }

    /**
     * Print the composite message and the embedded stack trace to the specified writer.
     *
     * @param pw the print writer
     */
    public void printStackTrace( PrintWriter pw )
    {
        if ( getCause() == null )
        {
            super.printStackTrace( pw );
        }
        else
        {
            pw.println( this );
            getCause().printStackTrace( pw );
        }
    }

    /**
     * Retrieve the innermost cause of this exception, if any.
     * <p>Currently just traverses NestedRuntimeException causes. Will use
     * the JDK 1.4 exception cause mechanism once Spring requires JDK 1.4.
     *
     * @return the innermost exception, or <code>null</code> if none
     */
    public Throwable getRootCause()