Source:
<code>public MantaObjectResponse put(final String rawPath, final InputStream source, final long contentLength, final MantaHttpHeaders headers, final MantaMetadata metadata) throws IOException { Validate.notBlank(rawPath, "rawPath must not be blank"); Validate.notNull(source, "Input stream must not be null"); final String path = formatPath(rawPath); final ContentType contentType; <START> if (BooleanUtils.isTrue(config.isContentTypeDetectionEnabled())) { <END> contentType = ContentTypeLookup.findOrDefaultContentType(headers, ContentType.APPLICATION_OCTET_STREAM); } else { contentType = ContentType.APPLICATION_OCTET_STREAM; } final int preLoadSize = config.getUploadBufferSize(); final HttpEntity entity; if (contentLength < 0) { if (source.getClass().equals(FileInputStream.class)) { FileInputStream fsin = (FileInputStream)source; entity = new InputStreamEntity(fsin, fsin.getChannel().size(), contentType); } else { byte[] preLoad = new byte[preLoadSize]; int read = IOUtils.read(source, preLoad); if (read < preLoadSize) { entity = new ExposedByteArrayEntity(preLoad, 0, read, contentType); } else { ByteArrayInputStream bin = new ByteArrayInputStream(preLoad); SequenceInputStream sin = new SequenceInputStream(bin, source); entity = new InputStreamEntity(sin, contentType); } } } else { if (contentLength <= preLoadSize && contentLength <= Integer.MAX_VALUE) { byte[] preLoad = new byte[(int)contentLength]; IOUtils.read(source, preLoad); entity = new ExposedByteArrayEntity(preLoad, contentType); } else { entity = new InputStreamEntity(source, contentLength, contentType); } } return httpHelper.httpPut(path, headers, entity, metadata); }</code><technical_language>struck me. do a static private method for this MantaClient, this cut code duplication. do think</technical_language>

Target:
public MantaObjectResponse put(final String rawPath, final InputStream source, final long contentLength, final MantaHttpHeaders headers, final MantaMetadata metadata) throws IOException { Validate.notBlank(rawPath, "rawPath must not be blank"); Validate.notNull(source, "Input stream must not be null"); final String path = formatPath(rawPath); final ContentType contentType = ContentTypeLookup.findOrDefaultContentType(headers, ContentType.APPLICATION_OCTET_STREAM); final int preLoadSize = config.getUploadBufferSize(); final HttpEntity entity; if (contentLength < 0) { if (source.getClass().equals(FileInputStream.class)) { FileInputStream fsin = (FileInputStream)source; entity = new InputStreamEntity(fsin, fsin.getChannel().size(), contentType); } else { byte[] preLoad = new byte[preLoadSize]; int read = IOUtils.read(source, preLoad); if (read < preLoadSize) { entity = new ExposedByteArrayEntity(preLoad, 0, read, contentType); } else { ByteArrayInputStream bin = new ByteArrayInputStream(preLoad); SequenceInputStream sin = new SequenceInputStream(bin, source); entity = new InputStreamEntity(sin, contentType); } } } else { if (contentLength <= preLoadSize && contentLength <= Integer.MAX_VALUE) { byte[] preLoad = new byte[(int)contentLength]; IOUtils.read(source, preLoad); entity = new ExposedByteArrayEntity(preLoad, contentType); } else { entity = new InputStreamEntity(source, contentLength, contentType); } } return httpHelper.httpPut(path, headers, entity, metadata); }