Mostly missing Javadoc in org.apache.hc.client5.http.entity and minor

clean ups
This commit is contained in:
Gary Gregory 2023-06-28 21:01:50 -04:00 committed by Gary Gregory
parent 635f5f475b
commit 09ae5f212a
4 changed files with 95 additions and 43 deletions

View File

@ -48,7 +48,7 @@ public abstract class Resource implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Returns resource content as a {@link InputStream}. * Returns resource content as an {@link InputStream}.
* *
* @throws ResourceIOException * @throws ResourceIOException
*/ */

View File

@ -47,6 +47,7 @@ public class DecompressingEntity extends HttpEntityWrapper {
private static final int BUFFER_SIZE = 1024 * 2; private static final int BUFFER_SIZE = 1024 * 2;
private final InputStreamFactory inputStreamFactory; private final InputStreamFactory inputStreamFactory;
/** /**
* {@link #getContent()} method must return the same {@link InputStream} * {@link #getContent()} method must return the same {@link InputStream}
* instance when DecompressingEntity is wrapping a streaming entity. * instance when DecompressingEntity is wrapping a streaming entity.
@ -54,7 +55,7 @@ public class DecompressingEntity extends HttpEntityWrapper {
private InputStream content; private InputStream content;
/** /**
* Creates a new {@link DecompressingEntity}. * Constructs a new {@link DecompressingEntity}.
* *
* @param wrapped the non-null {@link HttpEntity} to be wrapped * @param wrapped the non-null {@link HttpEntity} to be wrapped
* @param inputStreamFactory factory to create decompressing stream. * @param inputStreamFactory factory to create decompressing stream.

View File

@ -92,7 +92,9 @@ public class EntityBuilder {
} }
/** /**
* Returns entity content as a string if set using {@link #setText(String)} method. * Gets the entity content as a string if set using {@link #setText(String)}.
*
* @return the entity content as a string, may be null.
*/ */
public String getText() { public String getText() {
return text; return text;
@ -101,11 +103,14 @@ public class EntityBuilder {
/** /**
* Sets entity content as a string. This method is mutually exclusive with * Sets entity content as a string. This method is mutually exclusive with
* {@link #setBinary(byte[])}, * {@link #setBinary(byte[])},
* {@link #setStream(java.io.InputStream)} , * {@link #setStream(java.io.InputStream)},
* {@link #setSerializable(java.io.Serializable)} , * {@link #setSerializable(java.io.Serializable)},
* {@link #setParameters(java.util.List)}, * {@link #setParameters(java.util.List)},
* {@link #setParameters(NameValuePair...)} * {@link #setParameters(NameValuePair...)}
* {@link #setFile(java.io.File)} methods. * {@link #setFile(java.io.File)} methods.
*
* @param text entity content as a string.
* @return this
*/ */
public EntityBuilder setText(final String text) { public EntityBuilder setText(final String text) {
clearContent(); clearContent();
@ -114,8 +119,10 @@ public class EntityBuilder {
} }
/** /**
* Returns entity content as a byte array if set using * Gets entity content as a byte array if set using
* {@link #setBinary(byte[])} method. * {@link #setBinary(byte[])}.
*
* @return entity content as a byte array.
*/ */
public byte[] getBinary() { public byte[] getBinary() {
return binary; return binary;
@ -124,11 +131,14 @@ public class EntityBuilder {
/** /**
* Sets entity content as a byte array. This method is mutually exclusive with * Sets entity content as a byte array. This method is mutually exclusive with
* {@link #setText(String)}, * {@link #setText(String)},
* {@link #setStream(java.io.InputStream)} , * {@link #setStream(java.io.InputStream)},
* {@link #setSerializable(java.io.Serializable)} , * {@link #setSerializable(java.io.Serializable)},
* {@link #setParameters(java.util.List)}, * {@link #setParameters(java.util.List)},
* {@link #setParameters(NameValuePair...)} * {@link #setParameters(NameValuePair...)}
* {@link #setFile(java.io.File)} methods. * {@link #setFile(java.io.File)}.
*
* @param binary The new entity content as a byte array.
* @return this
*/ */
public EntityBuilder setBinary(final byte[] binary) { public EntityBuilder setBinary(final byte[] binary) {
clearContent(); clearContent();
@ -137,21 +147,26 @@ public class EntityBuilder {
} }
/** /**
* Returns entity content as a {@link InputStream} if set using * Gets entity content as an {@link InputStream} if set using
* {@link #setStream(java.io.InputStream)} method. * {@link #setStream(java.io.InputStream)} method.
*
* @return entity content as an {@link InputStream}
*/ */
public InputStream getStream() { public InputStream getStream() {
return stream; return stream;
} }
/** /**
* Sets entity content as a {@link InputStream}. This method is mutually exclusive with * Sets entity content as an {@link InputStream}. This method is mutually exclusive with
* {@link #setText(String)}, * {@link #setText(String)},
* {@link #setBinary(byte[])}, * {@link #setBinary(byte[])},
* {@link #setSerializable(java.io.Serializable)} , * {@link #setSerializable(java.io.Serializable)},
* {@link #setParameters(java.util.List)}, * {@link #setParameters(java.util.List)},
* {@link #setParameters(NameValuePair...)} * {@link #setParameters(NameValuePair...)}
* {@link #setFile(java.io.File)} methods. * {@link #setFile(java.io.File)}.
*
* @param stream The new entity content as an InputStream.
* @return this
*/ */
public EntityBuilder setStream(final InputStream stream) { public EntityBuilder setStream(final InputStream stream) {
clearContent(); clearContent();
@ -160,9 +175,11 @@ public class EntityBuilder {
} }
/** /**
* Returns entity content as a parameter list if set using * Gets entity content as a parameter list if set using
* {@link #setParameters(java.util.List)} or * {@link #setParameters(java.util.List)} or
* {@link #setParameters(NameValuePair...)} methods. * {@link #setParameters(NameValuePair...)}.
*
* @return entity content as a parameter list.
*/ */
public List<NameValuePair> getParameters() { public List<NameValuePair> getParameters() {
return parameters; return parameters;
@ -172,9 +189,12 @@ public class EntityBuilder {
* Sets entity content as a parameter list. This method is mutually exclusive with * Sets entity content as a parameter list. This method is mutually exclusive with
* {@link #setText(String)}, * {@link #setText(String)},
* {@link #setBinary(byte[])}, * {@link #setBinary(byte[])},
* {@link #setStream(java.io.InputStream)} , * {@link #setStream(java.io.InputStream)},
* {@link #setSerializable(java.io.Serializable)} , * {@link #setSerializable(java.io.Serializable)},
* {@link #setFile(java.io.File)} methods. * {@link #setFile(java.io.File)}.
*
* @param parameters entity content as a parameter list.
* @return this
*/ */
public EntityBuilder setParameters(final List<NameValuePair> parameters) { public EntityBuilder setParameters(final List<NameValuePair> parameters) {
clearContent(); clearContent();
@ -186,17 +206,22 @@ public class EntityBuilder {
* Sets entity content as a parameter list. This method is mutually exclusive with * Sets entity content as a parameter list. This method is mutually exclusive with
* {@link #setText(String)}, * {@link #setText(String)},
* {@link #setBinary(byte[])}, * {@link #setBinary(byte[])},
* {@link #setStream(java.io.InputStream)} , * {@link #setStream(java.io.InputStream)},
* {@link #setSerializable(java.io.Serializable)} , * {@link #setSerializable(java.io.Serializable)},
* {@link #setFile(java.io.File)} methods. * {@link #setFile(java.io.File)}.
*
* @param parameters entity content as a parameter list.
* @return this
*/ */
public EntityBuilder setParameters(final NameValuePair... parameters) { public EntityBuilder setParameters(final NameValuePair... parameters) {
return setParameters(Arrays.asList(parameters)); return setParameters(Arrays.asList(parameters));
} }
/** /**
* Returns entity content as a {@link Serializable} if set using * Gets entity content as a {@link Serializable} if set using
* {@link #setSerializable(java.io.Serializable)} method. * {@link #setSerializable(java.io.Serializable)} method.
*
* @return entity content as a {@link Serializable}.
*/ */
public Serializable getSerializable() { public Serializable getSerializable() {
return serializable; return serializable;
@ -206,10 +231,13 @@ public class EntityBuilder {
* Sets entity content as a {@link Serializable}. This method is mutually exclusive with * Sets entity content as a {@link Serializable}. This method is mutually exclusive with
* {@link #setText(String)}, * {@link #setText(String)},
* {@link #setBinary(byte[])}, * {@link #setBinary(byte[])},
* {@link #setStream(java.io.InputStream)} , * {@link #setStream(java.io.InputStream)},
* {@link #setParameters(java.util.List)}, * {@link #setParameters(java.util.List)},
* {@link #setParameters(NameValuePair...)} * {@link #setParameters(NameValuePair...)}
* {@link #setFile(java.io.File)} methods. * {@link #setFile(java.io.File)}.
*
* @param serializable entity content as a {@link Serializable}.
* @return this
*/ */
public EntityBuilder setSerializable(final Serializable serializable) { public EntityBuilder setSerializable(final Serializable serializable) {
clearContent(); clearContent();
@ -218,8 +246,10 @@ public class EntityBuilder {
} }
/** /**
* Returns entity content as a {@link File} if set using * Gets the entity content as a {@link File} if set using
* {@link #setFile(java.io.File)} method. * {@link #setFile(java.io.File)}.
*
* @return Gets the entity content as a {@link File}.
*/ */
public File getFile() { public File getFile() {
return file; return file;
@ -229,10 +259,13 @@ public class EntityBuilder {
* Sets entity content as a {@link File}. This method is mutually exclusive with * Sets entity content as a {@link File}. This method is mutually exclusive with
* {@link #setText(String)}, * {@link #setText(String)},
* {@link #setBinary(byte[])}, * {@link #setBinary(byte[])},
* {@link #setStream(java.io.InputStream)} , * {@link #setStream(java.io.InputStream)},
* {@link #setParameters(java.util.List)}, * {@link #setParameters(java.util.List)},
* {@link #setParameters(NameValuePair...)} * {@link #setParameters(NameValuePair...)}
* {@link #setSerializable(java.io.Serializable)} methods. * {@link #setSerializable(java.io.Serializable)}.
*
* @param file entity content as a {@link File}.
* @return this
*/ */
public EntityBuilder setFile(final File file) { public EntityBuilder setFile(final File file) {
clearContent(); clearContent();
@ -241,14 +274,19 @@ public class EntityBuilder {
} }
/** /**
* Returns {@link ContentType} of the entity, if set. * Gets the {@link ContentType} of the entity, may be null.
*
* @return the {@link ContentType} of the entity, may be null.
*/ */
public ContentType getContentType() { public ContentType getContentType() {
return contentType; return contentType;
} }
/** /**
* Sets {@link ContentType} of the entity. * Sets the {@link ContentType} of the entity.
*
* @param contentType the {@link ContentType} of the entity, may be null.
* @return this
*/ */
public EntityBuilder setContentType(final ContentType contentType) { public EntityBuilder setContentType(final ContentType contentType) {
this.contentType = contentType; this.contentType = contentType;
@ -256,14 +294,19 @@ public class EntityBuilder {
} }
/** /**
* Returns content encoding of the entity, if set. * Gets the content encoding of the entity, may be null.
*
* @return the content encoding of the entity, may be null.
*/ */
public String getContentEncoding() { public String getContentEncoding() {
return contentEncoding; return contentEncoding;
} }
/** /**
* Sets content encoding of the entity. * Sets the content encoding of the entity.
*
* @param contentEncoding the content encoding of the entity, may be null.
* @return this
*/ */
public EntityBuilder setContentEncoding(final String contentEncoding) { public EntityBuilder setContentEncoding(final String contentEncoding) {
this.contentEncoding = contentEncoding; this.contentEncoding = contentEncoding;
@ -271,14 +314,17 @@ public class EntityBuilder {
} }
/** /**
* Returns {@code true} if entity is to be chunk coded, {@code false} otherwise. * Tests if the entity is to be chunk coded ({@code true}), or not ({@code false}).
*
* @return {@code true} if entity is to be chunk coded, {@code false} otherwise.
*/ */
public boolean isChunked() { public boolean isChunked() {
return chunked; return chunked;
} }
/** /**
* Makes entity chunk coded. * Sets entities to be chunked.
* @return this
*/ */
public EntityBuilder chunked() { public EntityBuilder chunked() {
this.chunked = true; this.chunked = true;
@ -286,14 +332,18 @@ public class EntityBuilder {
} }
/** /**
* Returns {@code true} if entity is to be GZIP compressed, {@code false} otherwise. * Tests if entities are to be GZIP compressed ({@code true}), or not ({@code false}).
*
* @return {@code true} if entity is to be GZIP compressed, {@code false} otherwise.
*/ */
public boolean isGzipCompressed() { public boolean isGzipCompressed() {
return gzipCompressed; return gzipCompressed;
} }
/** /**
* Makes entity GZIP compressed. * Sets entities to be GZIP compressed.
*
* @return this
*/ */
public EntityBuilder gzipCompressed() { public EntityBuilder gzipCompressed() {
this.gzipCompressed = true; this.gzipCompressed = true;
@ -305,7 +355,9 @@ public class EntityBuilder {
} }
/** /**
* Creates new instance of {@link HttpEntity} based on the current state. * Builds a new instance of {@link HttpEntity} based on the current state.
*
* @return a new instance.
*/ */
public HttpEntity build() { public HttpEntity build() {
final AbstractHttpEntity e; final AbstractHttpEntity e;

View File

@ -302,12 +302,11 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
leaseCompleted(poolEntry); leaseCompleted(poolEntry);
})), Command.Priority.IMMEDIATE); })), Command.Priority.IMMEDIATE);
return; return;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("{} connection {} is closed", id, ConnPoolSupport.getId(connection));
}
poolEntry.discardConnection(CloseMode.IMMEDIATE);
} }
if (LOG.isDebugEnabled()) {
LOG.debug("{} connection {} is closed", id, ConnPoolSupport.getId(connection));
}
poolEntry.discardConnection(CloseMode.IMMEDIATE);
} }
} }
} }