CPD Results

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

Duplications

File Line
org/jomc/model/ModelContext.java 824
org/jomc/model/bootstrap/BootstrapContext.java 371
                InputStream in = null;
                final java.util.Properties p = new java.util.Properties();

                try
                {
                    in = new FileInputStream( platformProviders );
                    p.load( in );
                }
                finally
                {
                    if ( in != null )
                    {
                        in.close();
                    }
                }

                for ( Map.Entry e : p.entrySet() )
                {
                    if ( e.getKey().toString().startsWith( providerNamePrefix ) )
                    {
                        final Class<T> provider = this.findClass( e.getValue().toString() );
                        if ( provider != null )
                        {
                            providers.put( e.getKey().toString(), provider );
                        }
                    }
                }
            }

            final Enumeration<URL> serviceProviders =
                this.findResources( "META-INF/services/" + providerClass.getName() );

            while ( serviceProviders.hasMoreElements() )
            {
                final URL url = serviceProviders.nextElement();
                final BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream(), "UTF-8" ) );

                String line = null;
                while ( ( line = reader.readLine() ) != null )
                {
                    if ( line.contains( "#" ) )
                    {
                        continue;
                    }

                    final Class<T> provider = this.findClass( line );
                    if ( provider != null )
                    {
                        providers.put( providerNamePrefix + providers.size(), provider );
                    }
                }

                reader.close();
            }

            return providers.values();
        }
        catch ( final IOException e )
        {
            throw new BootstrapException( e );

File Line
org/jomc/model/ModelContext.java 795
org/jomc/model/bootstrap/BootstrapContext.java 351
    {
        try
        {
            final String providerNamePrefix = providerClass.getName() + ".";
            final Map<String, Class<T>> providers = new TreeMap<String, Class<T>>( new Comparator<String>()
            {

                public int compare( final String key1, final String key2 )
                {
                    return key1.compareTo( key2 );
                }

            } );

            final File platformProviders = new File( new StringBuilder().append( System.getProperty( "java.home" ) ).
                append( File.separator ).append( "jre" ).append( File.separator ).append( "lib" ).
                append( File.separator ).append( "jomc.properties" ).toString() );

            if ( platformProviders.exists() )
            {