Skip to content

Instantly share code, notes, and snippets.

View liptga's full-sized avatar

Gábor Lipták liptga

View GitHub Profile
@liptga
liptga / PaymentApplication.java
Last active August 30, 2017 09:32
Spring Boot Application Class
@SpringBootApplication
@EnableHystrix
public class PaymentApplication {
public static void main(String[] args) {
SpringApplication.run(PaymentApplication.class, args);
}
}
@Override
@HystrixCommand
public String fetchPaymentToken(GenerateTokenParameterData generateTokenParameterData) {
return payunityTokenResponse.getId();
}
@liptga
liptga / Hystrix Timeout Exception
Last active August 30, 2017 11:50
Hystrix timeout exception
[ERROR] 2017-08-19 09:20:57,545 unexpected exception occurred. [] [http-nio-8110-exec-1]
java.lang.reflect.UndeclaredThrowableException: null
at com.sun.proxy.$Proxy135.fetchPaymentToken(Unknown Source)
at xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxxxxxxxxxxxx.java:87)
at xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxxxxxxxxxxxxxxxxx.java:76)
at sun.reflect.GeneratedMethodAccessor215.invoke(Unknown Source)
...
...
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.TimeoutException: null
@liptga
liptga / Hanging Thread Stack
Last active August 30, 2017 11:50
Hanging thread stack example
"hystrix-xxxxxxxxxxxxxxxxxxServiceImpl-6" #155 daemon prio=5 os_prio=0 tid=0x00007fbb64506000 nid=0x7b03 runnable [0x00007fbbb85d3000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
...
...
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652)
...
@liptga
liptga / Simulating Socket Read Timeout.sh
Created August 30, 2017 12:09
Simulating Socket Read Timeout
iptables -A INPUT -p tcp -m tcp -s 123.123.123.123 --tcp-flags PSH PSH --sport 443 -j DROP
@liptga
liptga / application.yml
Created August 30, 2017 12:15
Application.yml example for timeouts
rest:
connection:
connection-request-timeout: 30000
connect-timeout: 30000
read-timeout: 30000
@liptga
liptga / RestTemplateConfiguration.java
Created August 30, 2017 12:17
RestTemplateConfiguration example with setting socket timeouts
@Configuration
public class RestTemplateConfiguration {
private static final String CUSTOM_HTTP_REQUEST_FACTORY_BEAN_NAME = "customHttpRequestFactory";
/**
* See https://stackoverflow.com/a/36991745/337621
* @return
*/
@Bean(CUSTOM_HTTP_REQUEST_FACTORY_BEAN_NAME)
@ConfigurationProperties(prefix = "rest.connection")
/**
Prints:
" "
"fdsajfklsdjalkf"
" "
"safd"
" "
"safsdfasdf"
" "
package at.liptakg.lombokdemo;
public class POJO
{
}
package at.liptakg.lombokdemo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper=true, exclude="name")
@AllArgsConstructor
public class WrongEntityExample extends POJO{