Skip to content

Commit aa25145

Browse files
committed
Apache HttpClient: expose observation and SSE packages in Javadoc groups
Fix Javadoc warnings in httpclient5-sse package
1 parent c82268d commit aa25145

File tree

8 files changed

+48
-13
lines changed

8 files changed

+48
-13
lines changed

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/BackoffStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface BackoffStrategy {
3838
* @param attempt consecutive reconnect attempt number (1-based)
3939
* @param previousDelayMs last delay used (0 for first attempt)
4040
* @param serverRetryHintMs value from server 'retry:' (ms) or HTTP Retry-After, or null if none
41-
* @return delay in milliseconds (>= 0)
41+
* @return delay in milliseconds, greater than or equal to {@code 0}
4242
*/
4343
long nextDelayMs(int attempt, long previousDelayMs, Long serverRetryHintMs);
4444

@@ -49,7 +49,7 @@ public interface BackoffStrategy {
4949
* @param attempt consecutive reconnect attempt number (1-based)
5050
* @param previousDelayMs last delay used (0 for first attempt)
5151
* @param serverRetryHintMs value from server 'retry:' (ms) or HTTP Retry-After, or null if none
52-
* @return true to reconnect, false to stop
52+
* @return {@code true} to reconnect, {@code false} to stop
5353
*/
5454
default boolean shouldReconnect(final int attempt, final long previousDelayMs, final Long serverRetryHintMs) {
5555
return true;

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/EventSourceListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* <p>Implementations should keep handlers lightweight and non-blocking.
3434
* If you need to do heavy work, offload to your own executor.</p>
3535
*
36-
* <h3>Invocation & threading</h3>
36+
* <h3>Invocation &amp; threading</h3>
3737
* <ul>
3838
* <li>Methods may be invoked on an internal callback executor supplied to the
3939
* {@code EventSource} (or on the caller thread if none was supplied).

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/SseExecutor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static CloseableHttpAsyncClient getSharedClient() {
126126
*
127127
* <p>Use this when you want to set defaults such as headers, backoff,
128128
* parser strategy (char vs. byte), or custom executors for scheduling and callbacks.</p>
129+
* @return a new {@link SseExecutorBuilder}
129130
*/
130131
public static SseExecutorBuilder custom() {
131132
return new SseExecutorBuilder();
@@ -137,6 +138,7 @@ public static SseExecutorBuilder custom() {
137138
* <p>Streams opened by this executor will share one underlying {@link CloseableHttpAsyncClient}
138139
* instance. {@link #close()} will be a no-op; call {@link #closeSharedClient()} to
139140
* explicitly shut the shared client down (for tests / application shutdown).</p>
141+
* @return a new {@link SseExecutor}
140142
*/
141143
public static SseExecutor newInstance() {
142144
final CloseableHttpAsyncClient c = getSharedClient();
@@ -152,6 +154,8 @@ public static SseExecutor newInstance() {
152154
* @param client an already constructed async client
153155
* @throws NullPointerException if {@code client} is {@code null}
154156
* @throws IllegalStateException if the client is shutting down or shut down
157+
* @return a new {@link SseExecutor}
158+
*
155159
*/
156160
public static SseExecutor newInstance(final CloseableHttpAsyncClient client) {
157161
Args.notNull(client, "HTTP Async Client");
@@ -164,6 +168,7 @@ public static SseExecutor newInstance(final CloseableHttpAsyncClient client) {
164168
* Closes and clears the shared async client, if present.
165169
*
166170
* <p>Useful for tests or orderly application shutdown.</p>
171+
* @throws IOException if closing the client fails
167172
*/
168173
public static void closeSharedClient() throws IOException {
169174
LOCK.lock();
@@ -213,6 +218,7 @@ public static void closeSharedClient() throws IOException {
213218
/**
214219
* Closes the underlying async client if this executor does <em>not</em> use
215220
* the process-wide shared client. No-op otherwise.
221+
* @throws IOException if closing the client fails
216222
*/
217223
public void close() throws IOException {
218224
if (!isSharedClient) {
@@ -225,6 +231,7 @@ public void close() throws IOException {
225231
*
226232
* @param uri target SSE endpoint (must produce {@code text/event-stream})
227233
* @param listener event callbacks
234+
* @return the created {@link EventSource}
228235
*/
229236
public EventSource open(final URI uri, final EventSourceListener listener) {
230237
return open(uri, this.defaultHeaders, listener, this.defaultConfig,
@@ -237,6 +244,7 @@ public EventSource open(final URI uri, final EventSourceListener listener) {
237244
* @param uri target SSE endpoint
238245
* @param headers extra request headers (merged with executor defaults)
239246
* @param listener event callbacks
247+
* @return the created {@link EventSource}
240248
*/
241249
public EventSource open(final URI uri,
242250
final Map<String, String> headers,
@@ -252,6 +260,7 @@ public EventSource open(final URI uri,
252260
* @param headers extra request headers (merged with executor defaults)
253261
* @param listener event callbacks
254262
* @param config reconnect/backoff config
263+
* @return the created {@link EventSource}
255264
*/
256265
public EventSource open(final URI uri,
257266
final Map<String, String> headers,
@@ -271,6 +280,7 @@ public EventSource open(final URI uri,
271280
* @param parser parsing strategy ({@link SseParser#CHAR} or {@link SseParser#BYTE})
272281
* @param scheduler scheduler for reconnects (nullable → internal shared scheduler)
273282
* @param callbackExecutor executor for listener callbacks (nullable → run inline)
283+
* @return the created {@link EventSource}
274284
*/
275285
public EventSource open(final URI uri,
276286
final Map<String, String> headers,
@@ -292,6 +302,7 @@ public EventSource open(final URI uri,
292302

293303
/**
294304
* Returns the underlying {@link CloseableHttpAsyncClient}.
305+
* @return the client
295306
*/
296307
public CloseableHttpAsyncClient getClient() {
297308
return client;

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/SseExecutorBuilder.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public final class SseExecutorBuilder {
7777
/**
7878
* Supplies a custom async HTTP client. The caller owns its lifecycle and
7979
* {@link SseExecutor#close()} will close it.
80+
* @param client the client to use
81+
* @return this builder
8082
*/
8183
public SseExecutorBuilder setHttpClient(final CloseableHttpAsyncClient client) {
8284
this.client = Args.notNull(client, "HTTP Async Client");
@@ -86,6 +88,8 @@ public SseExecutorBuilder setHttpClient(final CloseableHttpAsyncClient client) {
8688
/**
8789
* Sets the scheduler to use for reconnect delays. If not provided, the internal shared
8890
* scheduler is used.
91+
* @param scheduler the scheduler to use
92+
* @return this builder
8993
*/
9094
public SseExecutorBuilder setScheduler(final ScheduledExecutorService scheduler) {
9195
this.scheduler = scheduler;
@@ -95,6 +99,8 @@ public SseExecutorBuilder setScheduler(final ScheduledExecutorService scheduler)
9599
/**
96100
* Sets the executor used to dispatch {@link EventSourceListener} callbacks.
97101
* If not provided, callbacks run inline on the I/O thread.
102+
* @param callbackExecutor the executor to use
103+
* @return this builder
98104
*/
99105
public SseExecutorBuilder setCallbackExecutor(final Executor callbackExecutor) {
100106
this.callbackExecutor = callbackExecutor;
@@ -103,6 +109,8 @@ public SseExecutorBuilder setCallbackExecutor(final Executor callbackExecutor) {
103109

104110
/**
105111
* Sets the default reconnect/backoff configuration applied to opened streams.
112+
* @param cfg the reconnect configuration
113+
* @return this builder
106114
*/
107115
public SseExecutorBuilder setEventSourceConfig(final EventSourceConfig cfg) {
108116
this.config = Args.notNull(cfg, "EventSourceConfig");
@@ -111,6 +119,8 @@ public SseExecutorBuilder setEventSourceConfig(final EventSourceConfig cfg) {
111119

112120
/**
113121
* Replaces the default headers (sent on every opened stream).
122+
* @param headers the headers to use
123+
* @return this builder
114124
*/
115125
public SseExecutorBuilder setDefaultHeaders(final Map<String, String> headers) {
116126
this.defaultHeaders.clear();
@@ -122,6 +132,9 @@ public SseExecutorBuilder setDefaultHeaders(final Map<String, String> headers) {
122132

123133
/**
124134
* Adds or replaces a single default header.
135+
* @param name the header name
136+
* @param value the header value
137+
* @return this builder
125138
*/
126139
public SseExecutorBuilder addDefaultHeader(final String name, final String value) {
127140
this.defaultHeaders.put(Args.notNull(name, "name"), value);
@@ -131,6 +144,8 @@ public SseExecutorBuilder addDefaultHeader(final String name, final String value
131144
/**
132145
* Chooses the parser strategy: {@link SseParser#CHAR} (spec-level, default)
133146
* or {@link SseParser#BYTE} (byte-level framing with minimal decoding).
147+
* @param parser the parser strategy to use
148+
* @return this builder
134149
*/
135150
public SseExecutorBuilder setParserStrategy(final SseParser parser) {
136151
this.parserStrategy = parser != null ? parser : SseParser.CHAR;
@@ -139,6 +154,7 @@ public SseExecutorBuilder setParserStrategy(final SseParser parser) {
139154

140155
/**
141156
* Builds the {@link SseExecutor}.
157+
* @return a new {@link SseExecutor}
142158
*/
143159
public SseExecutor build() {
144160
final CloseableHttpAsyncClient c = (client != null) ? client : SseExecutor.getSharedClient();

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/impl/ServerSentEventReader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
* <li>{@code retry} is parsed without creating a substring; only {@code data/event/id} values
3939
* create substrings when needed.</li>
4040
* </ul>
41-
* </p>
4241
*/
4342
@Internal
4443
public final class ServerSentEventReader {

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/impl/SseParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public enum SseParser {
4444
*/
4545
CHAR,
4646
/**
47-
* ByteBuffer → byte-level framing & minimal decode.
47+
* ByteBuffer → byte-level framing &amp; minimal decode.
4848
*/
4949
BYTE
5050
}

httpclient5-sse/src/main/java/org/apache/hc/client5/http/sse/package-info.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,31 @@
5454
* </ul>
5555
*
5656
* <h2>Quick start</h2>
57-
* <pre>{@code
57+
* <pre>
5858
* import java.net.URI;
5959
* import java.util.Collections;
6060
* import org.apache.hc.client5.http.sse.*;
6161
*
6262
* SseExecutor exec = SseExecutor.newInstance(); // shared async client
6363
*
6464
* EventSourceListener listener = new EventSourceListener() {
65-
* @Override public void onOpen() { System.out.println("open"); }
66-
* @Override public void onEvent(String id, String type, String data) {
65+
* &#64;Override public void onOpen() { System.out.println("open"); }
66+
* &#64;Override public void onEvent(String id, String type, String data) {
6767
* System.out.println(type + " id=" + id + " data=" + data);
6868
* }
69-
* @Override public void onClosed() { System.out.println("closed"); }
70-
* @Override public void onFailure(Throwable t, boolean willReconnect) {
69+
* &#64;Override public void onClosed() { System.out.println("closed"); }
70+
* &#64;Override public void onFailure(Throwable t, boolean willReconnect) {
7171
* t.printStackTrace();
7272
* }
7373
* };
7474
*
7575
* EventSource es = exec.open(URI.create("https://example.com/stream"),
76-
* Collections.<String,String>emptyMap(),
76+
* Collections.&lt;String,String&gt;emptyMap(),
7777
* listener);
7878
* es.start();
7979
*
8080
* Runtime.getRuntime().addShutdownHook(new Thread(es::cancel));
81-
* }</pre>
81+
* </pre>
8282
*
8383
* <h2>Configuration</h2>
8484
* <ul>

pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<tag>5.7-alpha1-SNAPSHOT</tag>
5252
</scm>
5353

54-
<distributionManagement>
54+
<distributionManagement>
5555
<site>
5656
<id>apache.website</id>
5757
<name>Apache HttpComponents Website</name>
@@ -493,6 +493,15 @@
493493
<title>Apache HttpClient Windows features</title>
494494
<packages>org.apache.hc.client5.http.impl.win*</packages>
495495
</group>
496+
<group>
497+
<title>Apache HttpClient Observations</title>
498+
<packages>org.apache.hc.client5.http.observation*</packages>
499+
</group>
500+
<group>
501+
<title>Apache HttpClient SSE</title>
502+
<packages>org.apache.hc.client5.http.sse*</packages>
503+
</group>
504+
496505
</groups>
497506
</configuration>
498507
<reportSets>

0 commit comments

Comments
 (0)