Skip to content

Instantly share code, notes, and snippets.

View Shawyeok's full-sized avatar

Yike Xiao Shawyeok

  • Beijing, China
  • 09:35 (UTC +08:00)
View GitHub Profile
@Shawyeok
Shawyeok / README.md
Last active November 2, 2026 12:56
Spring Cloud Gateway Server WebMVC: upstream abort mid-body is logged as unhandled ERROR and dispatched to /error (reproducer)

Spring Cloud Gateway Server WebMVC: upstream abort mid-body → Tomcat ERROR + /error dispatch

This reproducer is a single file: Spring Boot 4.0.9, Spring Cloud 2025.1.4, spring-cloud-gateway-server-webmvc 5.0.4, Tomcat 11.0.27.

git clone https://gist.github.com/8bb7604a03b63598d0946a6a05dcd9f2.git scg-upstream-abort && cd scg-upstream-abort
mvn test   # JDK 21+

UpstreamAbortTest starts the gateway with a single route, route("sse").POST("/sse", http()).before(uri(upstream)), and a raw-socket upstream that:

@Shawyeok
Shawyeok / ConcurrentRefreshTest.java
Created November 2, 2026 09:25
Spring Authorization Server: concurrent refresh_token grants with reuseRefreshTokens=false lose updates (reproducer, run: gradle test)
package repro;
import java.security.Principal;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CyclicBarrier;
@Shawyeok
Shawyeok / repro_empty_ledger_loss.sh
Created June 22, 2026 08:20
Apache Pulsar: reproduce silent loss / stuck backlog producing into an empty fenced+CLOSED head ledger (BK-4812 family)
#!/usr/bin/env bash
#
# Reproduces silent message loss / stuck backlog when a producer writes the
# FIRST message into a managed-ledger whose empty head ledger has been fenced
# and CLOSED in metadata (length=0, lastEntryId=-1) by BookKeeper auto-recovery,
# while the broker still holds that ledger OPEN in memory.
#
# Root cause family: https://github.com/apache/bookkeeper/issues/4812
#
# Cluster: 1 ZooKeeper + 1 broker + 3 bookies, all on a user-defined Docker
@Shawyeok
Shawyeok / JarConflictFinder.java
Created March 24, 2025 09:24
JarConflictFinder: A Java tool to identify duplicate classes across multiple JAR files in your project. This tool helps detect potential classpath conflicts by scanning directories or individual JAR files and reporting classes that appear in multiple JARs.
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
public class JarConflictFinder {
private Map<String, List<String>> classLocations = new HashMap<>();
# java -jar summary-benchmarks.jar -t 24
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openjdk.jmh.util.Utils (file:/root/summary-benchmarks-2.jar) to method java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of org.openjdk.jmh.util.Utils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
# JMH version: 1.37
# VM version: JDK 11.0.25, OpenJDK 64-Bit Server VM, 11.0.25+9-LTS
# VM invoker: /usr/lib/jvm/java-11-openjdk-11.0.25.0.9-3.el9.x86_64/bin/java
# VM options: <none>
@Shawyeok
Shawyeok / worker.js
Created March 25, 2023 05:37
Setup a free openai api proxy with cloudflare workers
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
url.hostname = 'api.openai.com'
const modifiedRequest = new Request(url.toString(), {
headers: request.headers,
method: request.method,
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.codec.Utf8StringCodec;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.IOException;
import java.nio.ByteBuffer;
@Shawyeok
Shawyeok / hs_err_pid7.log
Created November 6, 2019 14:42
JVM crashed with SIGSEGV C2 java.lang.StringBuilder.append
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f5665fef9be, pid=7, tid=0x00007f56574c3700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_191-b12) (build 1.8.0_191-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.191-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# J 6022 C2 java.lang.StringBuilder.append(Ljava/lang/String;)Ljava/lang/StringBuilder; (8 bytes) @ 0x00007f5665fef9be [0x00007f5665fef980+0x3e]
#
@Shawyeok
Shawyeok / docker-compose.yml
Created March 22, 2017 18:22
Test docker compose network, only link without ports/expose.
version: '2.0'
services:
client:
image: busybox
command: [sh, -c, 'echo ping | nc server 1234']
links:
- server
server:
image: busybox
command: [nc, -l, -p, '1234']