CPD Results

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

Duplications

File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 138
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 585
                () -> key(targetLocator)));

        final Object[] sourceObject_ = new Object[1];
        fileContext.sourceObjectConsumer(
            ofNullable(fileContext.sourceObjectConsumer()).orElse(
                sourceObject -> {
                    logger.trace("consuming source object: {}", sourceObject);
                    sourceObject_[0] = sourceObject;
                }));

        final Long[] sourceCopied_ = new Long[1];
        fileContext.sourceCopiedConsumer(
            ofNullable(fileContext.sourceCopiedConsumer()).orElse(
                sourceCopied -> {
                    logger.trace("consuming source copied: {}", sourceCopied);
                    sourceCopied_[0] = sourceCopied;
                }));

        final Object[] targetObject_ = new Object[1];
        fileContext.targetObjectConsumer(
            ofNullable(fileContext.targetObjectConsumer()).orElse(
                targetObject -> {
                    logger.trace("consuming target object: {}", targetObject);
                    targetObject_[0] = targetObject;
                }));

        final Long[] targetCopied_ = new Long[1];
        fileContext.targetCopiedConsumer(
            ofNullable(fileContext.targetCopiedConsumer()).orElse(
                targetCopied -> {
                    logger.trace("consuming target copied: {}", targetCopied);
                    targetCopied_[0] = targetCopied;
                }));

        final String[] pathName_ = new String[1];
        fileContext.pathNameConsumer(
            ofNullable(fileContext.pathNameConsumer()).orElse(
                pathName -> {
                    logger.trace("consuming path name: {}", pathName);
                    pathName_[0] = pathName;
                }));
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 677
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 842
        if (distributeFlag) {
            logger.trace("distributing...");
            final URI baseUri = uriInfo.getBaseUri();
            logger.trace("uriInfo.baseUri: {}", baseUri);
            final String path = uriInfo.getPath();
            logger.trace("uriInfo.path: {}", path);
            final List<Future<Response>> futures = new ArrayList<>();
            logger.trace("fileFronts: {}", fileFronts);
            for (final URI fileFront : fileFronts) {
                logger.trace("fileFront: {}", fileFront);
                if (!fileFront.isAbsolute()) {
                    logger.warn("not an absolute uri: {}", fileFront);
                    continue;
                }
                if (baseUri.equals(fileFront)) {
                    logger.trace("skipping self: " + fileFront);
                    continue;
                }
                final Client client = ClientBuilder.newClient()
                    .property(ClientProperties.CONNECT_TIMEOUT, 2000)
                    .property(ClientProperties.READ_TIMEOUT, 2000);
                final WebTarget target = client.target(fileFront).path(path)
                    .queryParam("distribute", Boolean.FALSE.toString());
                logger.trace("target: {}", target.getUri().toString());
//            try {
//                final Response response = target.request().put(
//                    Entity.entity(tempPath.toFile(), contentType));
//                logger.trace("response: {}", response);
//                logger.trace("response.status: {}", response.getStatusInfo());
//            } catch (final ProcessingException pe) {
//                logger.error("failed to distribute to " + fileFront, pe);
//            }
                final Future<Response> future = target.request().async().put(
                    Entity.entity(tempPath.toFile(), contentType));
                logger.trace("future: {}", future);
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 370
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 464
            () -> ByteBuffer.wrap(locator.getBytes(StandardCharsets.UTF_8)));

        final Object[] sourceObject_ = new Object[1];
        fileContext.sourceObjectConsumer(sourceObject -> {
            logger.trace("consuming source object: {}", sourceObject);
            sourceObject_[0] = sourceObject;
        });

        final Long[] sourceCopied_ = new Long[1];
        fileContext.sourceCopiedConsumer(sourceCopied -> {
            logger.trace("consuming source copied: {}", sourceCopied);
            sourceCopied_[0] = sourceCopied;
        });

        final Object[] targetObject_ = new Object[1];
        fileContext.targetObjectConsumer(targetObject -> {
            logger.trace("consuming target object: {}", targetObject);
            targetObject_[0] = targetObject;
        });

        final Long[] targetCopied_ = new Long[1];
        fileContext.targetCopiedConsumer(targetCopied -> {
            logger.trace("consuming target copied: {}", targetCopied);
            targetCopied_[0] = targetCopied;
        });

        final String[] pathName_ = new String[1];
        fileContext.pathNameConsumer(pathName -> {
            logger.trace("consuming path name: {}", pathName);
            pathName_[0] = pathName;
        });
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 284
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 398
            logger.trace("path name: {}", pathName);
            pathName_[0] = pathName;
        });

        fileBack.operate(fileContext); // ------------------------------ OPERATE

        if (distribute) {
            final URI baseUri = uriInfo.getBaseUri();
            logger.trace("uriInfo.baseUri: {}", baseUri);
            final String path = uriInfo.getPath();
            logger.trace("uriInfo.path: {}", path);
            final List<Future<Response>> futures = new ArrayList<>();
            for (final URI fileFront : fileFronts) {
                logger.trace("fileFront: {}", fileFront);
                if (baseUri.equals(fileFront)) {
                    logger.trace("skipping self: " + fileFront);
                    continue;
                }
                if (!fileFront.isAbsolute()) {
                    logger.warn("not an absolute uri: {}", fileFront);
                    continue;
                }
                final Client client = ClientBuilder.newClient()
                    .property(ClientProperties.CONNECT_TIMEOUT, 1000)
                    .property(ClientProperties.READ_TIMEOUT, 1000);
                final WebTarget target = client.target(fileFront).path(path)
                    .queryParam("source_locator", sourceLocator)
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 188
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 290
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 404
        if (distributeFlag) {
            final URI baseUri = uriInfo.getBaseUri();
            logger.trace("uriInfo.baseUri: {}", baseUri);
            final String path = uriInfo.getPath();
            logger.trace("uriInfo.path: {}", path);
            final List<Future<Response>> futures = new ArrayList<>();
            for (final URI fileFront : fileFronts) {
                logger.trace("fileFront: {}", fileFront);
                if (baseUri.equals(fileFront)) {
                    logger.trace("skipping self: " + fileFront);
                    continue;
                }
                if (!fileFront.isAbsolute()) {
                    logger.warn("not an absolute uri: {}", fileFront);
                    continue;
                }
                final Client client = ClientBuilder.newClient()
                    .property(ClientProperties.CONNECT_TIMEOUT, 1000)
                    .property(ClientProperties.READ_TIMEOUT, 1000);
                final WebTarget target = client.target(fileFront).path(path)
                    .queryParam("locator", targetLocator)
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 256
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 776
            targetLocator.getBytes(StandardCharsets.UTF_8)));

        final Object[] sourceObject_ = new Object[1];
        fileContext.sourceObjectConsumer(sourceObject -> {
            logger.trace("source object: {}", sourceObject);
            sourceObject_[0] = sourceObject;
        });

        final Long[] sourceCopied_ = new Long[1];
        fileContext.sourceCopiedConsumer(sourceCopied -> {
            logger.trace("source copied: {}", sourceCopied);
            sourceCopied_[0] = sourceCopied;
        });

        final Object[] targetObject_ = new Object[1];
        fileContext.targetObjectConsumer(targetObject -> {
            logger.trace("target object: {}", targetObject);
            targetObject_[0] = targetObject;
        });

        final Long[] targetCopied_ = new Long[0];
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 215
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 322
            }
            logger.trace("futures: {}", futures);
            futures.forEach(future -> {
                try {
                    final Response response = future.get();
                    logger.trace("response: {}", response);
                    logger.trace("response.statusInfo: {}",
                                 response.getStatusInfo());
                } catch (InterruptedException | ExecutionException e) {
                    logger.error("fail to get response", e);
                }
            });
        }

        return Response.noContent()
            .header(FileFrontConstants.HEADER_PATH_NAME, pathName_[0])
            .header(FileFrontConstants.HEADER_SOURCE_COPIED, sourceCopied_[0])
            .header(FileFrontConstants.HEADER_TARGET_COPIED, targetCopied_[0])
            .build();
    }


    @POST
File Line
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 628
com/github/jinahya/simple/file/front/AbstractLocatorsResource.java 809
            logger.trace("consuming target channel : {}", targetChannel);
            try {
                final long targetCopied = Files.copy(
                    tempPath, Channels.newOutputStream(targetChannel));
                logger.trace("target copied: {}", targetCopied);
                targetCopied_[0] = targetCopied;
            } catch (final IOException ioe) {
                final String message
                    = "failed to copy from temp path to target channel";
                logger.error(message, ioe);
                throw new WebApplicationException(message, ioe);
            }
        });

        final FileChannel[] sourceChannel_ = new FileChannel[1];
        fileContext.sourceChannelSupplier(true ? null : () -> { // _not_usd_!!!
            try {
                sourceChannel_[0] = FileChannel.open(
                    tempPath, StandardOpenOption.READ);
                logger.trace("suppling source channel: {}", sourceChannel_[0]);