ワンクリックで
profile-blocking
Find blocking calls in reactive WebFlux code that can cause performance issues and thread starvation
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Find blocking calls in reactive WebFlux code that can cause performance issues and thread starvation
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Answer questions about kite spots, weather forecasts, and live wind conditions from varun.surf by fetching its public LLM-friendly Markdown endpoints (llms.txt). Use when the user asks about a specific kite spot, current wind conditions, hourly/daily forecasts, or wants to compare spots/countries covered by varun.surf.
Stage and commit current changes with a well-crafted commit message following project conventions
Explain data flows, features, and code paths in the varun.surf application with visual diagrams and step-by-step breakdowns
Verify architecture health including layer violations, circular dependencies, package structure, and design pattern compliance
Quick security audit checking for hardcoded secrets, SSRF vectors, injection points, dependency issues, and missing security headers
Find concurrency issues including race conditions, deadlocks, unsafe shared state, and improper synchronization
| name | profile-blocking |
| description | Find blocking calls in reactive WebFlux code that can cause performance issues and thread starvation |
Identify blocking calls in the reactive codebase that can cause thread starvation, deadlocks, and performance degradation in Spring WebFlux applications.
Use Grep to search for these blocking call patterns:
.block() // Mono/Flux blocking subscription
.blockFirst() // Flux blocking first element
.blockLast() // Flux blocking last element
.blockOptional() // Mono blocking to Optional
.toFuture().get() // CompletableFuture blocking
.get() // Future.get() blocking
.join() // CompletableFuture.join()
Thread.sleep( // Thread sleep
Object.wait( // Object monitor wait
.await( // CountDownLatch, CyclicBarrier await
.acquire( // Semaphore blocking acquire
synchronized // Synchronized blocks (potential)
ReentrantLock.lock // Explicit locking
InputStream // Blocking input streams
OutputStream // Blocking output streams
FileInputStream // File I/O
FileOutputStream // File I/O
BufferedReader // Blocking readers
Scanner // Blocking scanner
new URL( // URL.openStream() is blocking
HttpURLConnection // Blocking HTTP
JdbcTemplate // Blocking JDBC
EntityManager // Blocking JPA
.save( // Repository blocking save
.findBy // Repository blocking find
DataSource // Direct datasource access
For each finding, determine if it's:
Acceptable blocking:
StructuredTaskScope (this project uses Java 24 virtual threads)@Scheduled methods running on separate thread poolMono.fromCallable() with .subscribeOn(Schedulers.boundedElastic())Problematic blocking:
@RestController methods returning Mono/FluxWebFilter implementationsMono.create() or Flux.create() without schedulerCheck for anti-patterns in reactive code:
// BAD: Blocking in map
mono.map(data -> {
blockingCall(); // Blocks event loop!
return result;
})
// BAD: Blocking in flatMap
flux.flatMap(item -> {
var result = blockingService.call(); // Blocks!
return Mono.just(result);
})
// GOOD: Proper offloading
mono.flatMap(data ->
Mono.fromCallable(() -> blockingCall())
.subscribeOn(Schedulers.boundedElastic())
)
Files to examine:
src/main/java/**/controller/*.java - REST endpointssrc/main/java/**/service/*.java - Service layersrc/main/java/**/strategy/*.java - Strategy implementationssrc/main/java/**/config/*.java - Configuration classesKnown acceptable patterns in this project:
StructuredTaskScope usage in AggregatorService (virtual threads).block() inside virtual thread contextsPatterns to flag:
.block() in controller methodsWebFilter or HandlerFilterFunctionThis project uses Java 24 with virtual threads. Check:
// Virtual thread factory usage
Thread.ofVirtual().factory()
// StructuredTaskScope usage (blocking is OK inside)
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
scope.fork(() -> blockingCall()); // OK - virtual thread
scope.join(); // OK - virtual thread blocks, not platform thread
}
Check OkHttp usage patterns:
// Synchronous call - check if on reactive thread
Response response = client.newCall(request).execute();
// Better: Use async
client.newCall(request).enqueue(callback);
// Or wrap properly
Mono.fromCallable(() -> client.newCall(request).execute())
.subscribeOn(Schedulers.boundedElastic())
## Blocking Call Analysis Report
### Summary
| Category | Count | Severity |
|----------|-------|----------|
| Direct .block() calls | X | High/Medium |
| Thread.sleep() | X | High |
| Blocking I/O | X | Medium |
| Synchronized blocks | X | Low |
| **Total potential issues** | **Y** | |
### Critical Issues (Event Loop Blocking)
#### [Issue Title]
**File**: `path/to/file.java:line`
**Pattern**: `.block()` in reactive chain
**Context**: Inside @RestController endpoint
**Risk**: Thread starvation, request timeouts
```java
// Current code
@GetMapping("/data")
public Mono<Data> getData() {
return service.fetchData()
.map(d -> blockingTransform(d)); // BLOCKS!
}
Fix:
@GetMapping("/data")
public Mono<Data> getData() {
return service.fetchData()
.flatMap(d -> Mono.fromCallable(() -> blockingTransform(d))
.subscribeOn(Schedulers.boundedElastic()));
}
| File | Line | Pattern | Context | Verdict |
|---|---|---|---|---|
| Service.java | 42 | .block() | Inside StructuredTaskScope | OK |
| Handler.java | 78 | Thread.sleep | Test code | OK |
These blocking calls are in appropriate contexts:
| File | Line | Pattern | Why It's OK |
|---|---|---|---|
| AggregatorService.java | 120 | .block() | Inside virtual thread scope |
| ForecastService.java | 85 | OkHttp.execute() | Wrapped in fromCallable |
src/main/java/.../Service.java:42 - response.block()
src/main/java/.../Service.java:87 - result.blockFirst()
src/main/java/.../Worker.java:23 - Thread.sleep(1000)
src/main/java/.../Reader.java:15 - new FileInputStream()
File.java:42 to bounded elastic scheduler
## Execution Steps
1. Use `Grep` to find all `.block()` calls
2. Use `Grep` to find `Thread.sleep`, `.await(`, `synchronized`
3. Use `Grep` to find blocking I/O patterns
4. Read each file to determine context (controller vs service vs test)
5. Check if blocking is inside StructuredTaskScope or virtual thread
6. Categorize findings by severity
7. Generate report with fix recommendations
## Notes
- Virtual threads (Java 21+) change the blocking calculus - blocking is OK on virtual threads
- This project uses StructuredTaskScope, so verify scope boundaries
- OkHttp is blocking by default but may be acceptable if not on event loop
- Focus on request-handling paths; scheduled tasks are lower priority
- Some `.block()` in tests is normal and acceptable
- Spring WebFlux Netty uses limited event loop threads - blocking them is critical