Skip to content

Instantly share code, notes, and snippets.

View progulin's full-sized avatar

Pavel Rogulin progulin

View GitHub Profile
import java.io.IOException;
import org.junit.Assert;
public class CheckedToUncheckedTest
{
private static final String MESSAGE = "Ooops!!!";
@org.junit.Test
public void test()
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.serialization.LongDeserializer;
import org.apache.kafka.common.serialization.LongSerializer;
@progulin
progulin / ExceptionWrapper.java
Last active April 6, 2019 18:09
It wraps throwable chain to unchecked Exception, which can be accepted by any client.Usefull for IPC.
public static final String MESSAGE_DELIMITER = System.lineSeparator() + "-> ";
public static RuntimeException wrapToRuntimeException(Throwable t) {
return wrapTo(RuntimeException.class, t);
}
public static <C extends Class<? extends RuntimeException>> RuntimeException wrapTo(C clazz, Throwable t) {
return wrapTo(clazz, t, Main::chainCauseMessages);
}
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
/**
* @author Pavel Rogulin, created at 31.01.13 0:25 MSK
*/
public class CycledClassInitialization
{
static class ClassA {
static {