Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View DarrenForsythe's full-sized avatar

Darren Forsythe DarrenForsythe

View GitHub Profile
@tschlegel
tschlegel / TokenRelayWithRefreshGatewayFilterFactory.java
Last active March 9, 2023 22:06
TokenReplayWithTokenRefresh with Spring Boot 2.2.0+
package com.example.gatewaywithtokenrelay.filter;
import java.time.Duration;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.client.OAuth2AuthorizeRequest;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientManager;
WebClient client = WebClient.builder()
.baseUrl("http://" + args[0])
.build();
Flux
.generate(AtomicLong::new, (state, sink) -> {
long i = state.getAndIncrement();
sink.next(i);
return state;
})
@dpryden
dpryden / ClassLoaderLeakExample.java
Created October 20, 2014 00:01
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,