Fork me on GitHub

CPD Results

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

Duplications

File Line
org/codehaus/mojo/webstart/dependency/task/UpdateManifestTask.java 101
org/codehaus/mojo/webstart/util/DefaultJarUtil.java 61
    private File updateManifestEntries( File jar, Map<String, String> manifestentries )
        throws MojoExecutionException
    {

        Manifest manifest = createManifest( jar, manifestentries );

        File updatedUnprocessedJarFile = new File( jar.getParent(), jar.getName() + "_updateManifestEntriesJar" );

        ZipFile originalJar = null;
        JarOutputStream targetJar = null;

        try
        {
            originalJar = new ZipFile( jar );
            targetJar = new JarOutputStream( new FileOutputStream( updatedUnprocessedJarFile ), manifest );

            // add all other entries from the original jar file
            Enumeration<? extends ZipEntry> entries = originalJar.entries();
            while ( entries.hasMoreElements() )
            {
                ZipEntry entry = entries.nextElement();

                // skip the original manifest
                if ( JarFile.MANIFEST_NAME.equals( entry.getName() ) )
                {
                    continue;
                }

                ZipEntry newEntry = new ZipEntry( entry.getName() );
                targetJar.putNextEntry( newEntry );

                // write content to stream if it is a file
                if ( !entry.isDirectory() )
                {
                    InputStream inputStream = null;
                    try
                    {
                        inputStream = originalJar.getInputStream( entry );
                        org.codehaus.plexus.util.IOUtil.copy( inputStream, targetJar );
                        inputStream.close();
                    }
                    finally
                    {
                        org.apache.maven.shared.utils.io.IOUtil.close( inputStream );
                    }
                }
                targetJar.closeEntry();
            }
            targetJar.close();
            originalJar.close();
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Error while updating manifest of " + jar.getName(), e );
        }
        finally
        {
            org.apache.maven.shared.utils.io.IOUtil.close( targetJar );
            ioUtil.close( originalJar );
        }
File Line
org/codehaus/mojo/webstart/AbstractJnlpMojo.java 492
org/codehaus/mojo/webstart/AbstractJnlpMojo.java 843
    private void processDependency( Artifact artifact )
        throws MojoExecutionException
    {
        // TODO: scope handler
        // Include runtime and compile time libraries
        if ( !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) &&
            !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) &&
            !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
        {
            String type = artifact.getType();
            if ( "jar".equals( type ) || "ejb-client".equals( type ) )
            {

                // FIXME when signed, we should update the manifest.
                // see http://www.mail-archive.com/turbine-maven-dev@jakarta.apache.org/msg08081.html
                // and maven1: maven-plugins/jnlp/src/main/org/apache/maven/jnlp/UpdateManifest.java
                // or shouldn't we?  See MOJO-7 comment end of October.
                final File toCopy = artifact.getFile();

                if ( toCopy == null )
                {
                    getLog().error( "artifact with no file: " + artifact );
                    getLog().error( "artifact download url: " + artifact.getDownloadUrl() );
                    getLog().error( "artifact repository: " + artifact.getRepository() );
                    getLog().error( "artifact repository: " + artifact.getVersion() );
                    throw new IllegalStateException(
                        "artifact " + artifact + " has no matching file, why? Check the logs..." );
                }
File Line
org/codehaus/mojo/webstart/dependency/task/SignTask.java 53
org/codehaus/mojo/webstart/dependency/task/UnsignTask.java 54
    public void check( JnlpDependencyConfig config )
    {
        if ( config == null )
        {
            throw new NullPointerException( "config can't be null" );
        }
        if ( config.getArtifact() == null )
        {
            throw new NullPointerException( "config.artifact can't be null" );
        }
        if ( config.getArtifact().getFile() == null )
        {
            throw new NullPointerException( "config.artifact.file can't be null" );
        }
        if ( !config.isSign() )
        {
            throw new IllegalStateException( "Can't sign if config.isSign is false" );
        }

        File file = config.getArtifact().getFile();

        boolean jarSigned;
        try
        {
            jarSigned = signTool.isJarSigned( file );
        }
        catch ( MojoExecutionException e )
        {
            throw new RuntimeException( e.getMessage(), e.getCause() );
        }

        if ( jarSigned && !config.isCanUnsign() )
        {
            throw new IllegalStateException( "Can't unsign the config.artifact.file if config.isCanUsign is false" );
        }
    }

    /**
     * {@inheritDoc}
     */
    public File execute( JnlpDependencyConfig config, File file )
File Line
org/codehaus/mojo/webstart/pack200/DefaultPack200Tool.java 165
org/codehaus/mojo/webstart/pack200/DefaultPack200Tool.java 195
            File pack200Jar = new File( jarFile.getParentFile(), jarFile.getName() + extension );

            deleteFile( pack200Jar );

            Map<String, String> propMap = new HashMap<String, String>();
            // Work around a JDK bug affecting large JAR files, see MWEBSTART-125
            propMap.put( Pack200.Packer.SEGMENT_LIMIT, String.valueOf( -1 ) );

            // set passFiles if available
            if ( passFiles != null && !passFiles.isEmpty() )
            {
                for ( int j = 0; j < passFiles.size(); j++ )
                {
                    propMap.put( Packer.PASS_FILE_PFX + j, passFiles.get( j ) );
                }
            }

            pack( jarFile, pack200Jar, propMap, gzip );
            setLastModified( pack200Jar, jarFile.lastModified() );