Skip to content

Commit 4552f83

Browse files
committed
Fix formatting #3233
1 parent b85de31 commit 4552f83

File tree

5 files changed

+19
-23
lines changed

5 files changed

+19
-23
lines changed

backpressure/src/main/java/com/iluwatar/backpressure/App.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
* producer to slow down or stop sending data when it's overwhelmed.
99
* <li>Prevents memory overflow, CPU thrashing, and resource exhaustion.
1010
* <li>Ensures fair usage of resources in distributed systems.
11-
* <li>Avoids buffer bloat and latency spikes.
12-
* Key concepts of this design paradigm involves
11+
* <li>Avoids buffer bloat and latency spikes. Key concepts of this design paradigm involves
1312
* <li>Publisher/Producer: Generates data.
1413
* <li>Subscriber/Consumer: Receives and processes data.
1514
*
16-
* <p>In this example we will create a {@link Publisher} and a {@link Subscriber}. Publisher will
17-
* emit a stream of integer values with a predefined delay. Subscriber takes 500 ms to process one
18-
* integer. Since the subscriber can't process the items fast enough we apply backpressure to the
19-
* publisher so that it will request 10 items first, process 5 items and request for the next 5
20-
* again. After processing 5 items subscriber will keep requesting for another 5 until the stream
21-
* ends.
15+
* <p>In this example we will create a {@link Publisher} and a {@link Subscriber}. Publisher
16+
* will emit a stream of integer values with a predefined delay. Subscriber takes 500 ms to
17+
* process one integer. Since the subscriber can't process the items fast enough we apply
18+
* backpressure to the publisher so that it will request 10 items first, process 5 items and
19+
* request for the next 5 again. After processing 5 items subscriber will keep requesting for
20+
* another 5 until the stream ends.
2221
*/
2322
@Slf4j
2423
public class App {
@@ -52,4 +51,4 @@ public static void main(String[] args) throws InterruptedException {
5251
latch = new CountDownLatch(1);
5352
latch.await();
5453
}
55-
}
54+
}

backpressure/src/main/java/com/iluwatar/backpressure/Publisher.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import java.time.Duration;
44
import reactor.core.publisher.Flux;
55

6-
/**
7-
* This class is the publisher that generates the data stream.
8-
*/
6+
/** This class is the publisher that generates the data stream. */
97
public class Publisher {
108

119
/**

backpressure/src/main/java/com/iluwatar/backpressure/Subscriber.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
import org.slf4j.LoggerFactory;
88
import reactor.core.publisher.BaseSubscriber;
99

10-
/**
11-
* This class is the custom subscriber that subscribes to the data stream.
12-
*/
10+
/** This class is the custom subscriber that subscribes to the data stream. */
1311
@Slf4j
1412
public class Subscriber extends BaseSubscriber<Integer> {
1513

1614
private static final Logger logger = LoggerFactory.getLogger(Subscriber.class);
1715

1816
@Override
1917
protected void hookOnSubscribe(@NonNull Subscription subscription) {
20-
request(10); //request 10 items initially
18+
request(10); // request 10 items initially
2119
}
2220

2321
@Override

backpressure/src/test/java/com/iluwatar/backpressure/PublisherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class PublisherTest {
1212
@Test
1313
public void testPublish() {
1414

15-
Flux<Integer> flux = publish(1, 3, 200);
15+
Flux<Integer> flux = publish(1, 3, 200);
1616

1717
StepVerifier.withVirtualTime(() -> flux)
1818
.expectSubscription()

backpressure/src/test/java/com/iluwatar/backpressure/SubscriberTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
public class SubscriberTest {
1010

11-
@RegisterExtension
12-
public LoggerExtension loggerExtension = new LoggerExtension();
11+
@RegisterExtension public LoggerExtension loggerExtension = new LoggerExtension();
1312

1413
@Test
1514
public void testSubscribe() throws InterruptedException {
@@ -21,9 +20,11 @@ public void testSubscribe() throws InterruptedException {
2120
App.latch.await();
2221

2322
String result = String.join(",", loggerExtension.getFormattedMessages());
24-
assertTrue(result.endsWith("onSubscribe(FluxConcatMapNoPrefetch." +
25-
"FluxConcatMapNoPrefetchSubscriber),request(10),onNext(1),process(1),onNext(2)," +
26-
"process(2),onNext(3),process(3),onNext(4),process(4),onNext(5),process(5),request(5)," +
27-
"onNext(6),process(6),onNext(7),process(7),onNext(8),process(8),onComplete()"));
23+
assertTrue(
24+
result.endsWith(
25+
"onSubscribe(FluxConcatMapNoPrefetch."
26+
+ "FluxConcatMapNoPrefetchSubscriber),request(10),onNext(1),process(1),onNext(2),"
27+
+ "process(2),onNext(3),process(3),onNext(4),process(4),onNext(5),process(5),request(5),"
28+
+ "onNext(6),process(6),onNext(7),process(7),onNext(8),process(8),onComplete()"));
2829
}
2930
}

0 commit comments

Comments
 (0)