Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mwiede's full-sized avatar

Matthias Wiedemann mwiede

View GitHub Profile
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import io.github.resilience4j.retry.Retry;
public final class WebserviceFactory{
static <T> T decorateWithRetryer(final T service, Retry retry) {
InvocationHandler invocationHandler = (proxy, method, args) -> retry.executeCheckedSupplier(() -> method.invoke(service, args));
@mwiede
mwiede / JschExec.java
Created June 25, 2020 22:16
Example reading and writing using exec channel
class JschExec {
private static String runCommand(Session session, String command, String... input) throws JSchException, IOException {
ChannelExec channel = (ChannelExec) session.openChannel("exec");
try {
channel.setCommand(command);
logger.debug("running command: {}", command);
final InputStream in = channel.getInputStream();
final InputStream errStream = channel.getErrStream();
@mwiede
mwiede / FeignTest.java
Created April 12, 2017 22:09
Junit test showing retryer of Feign
package de.matez.client;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.net.UnknownHostException;