Skip to content

Instantly share code, notes, and snippets.

@cherniag
cherniag / spring security misc
Created April 5, 2017 16:31
spring security misc
Exclude enpoint from security:
- WebSecurityConfigurerAdapter override:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/path/**");
}
@cherniag
cherniag / Spring core performance
Created February 23, 2017 13:17
Spring core performance
1. CachedIntrospectionResults.<init> takes a lot of time. Every BeanWrapper passes from CachedIntrospectionResults.forClass, it inokes
(if absent in static cache) Introspector.getBeanInfo which takes a lot of time. Cache usage occurs at
AbstractApplicationContext.finishBeanFactoryInitialization in scope of refresh() method but at the end of refresh method in finally block
there is call to resetCommonCaches:
protected void resetCommonCaches() {
ReflectionUtils.clearCache();
ResolvableType.clearCache();
CachedIntrospectionResults.clearClassLoader(getClassLoader()); // <---- remove it
}
@cherniag
cherniag / Spring AOP PreAuthorize
Created February 15, 2017 18:17
Spring AOP PreAuthorize
annotation: @PreAuthorize("hasRole('ROLE_DELETE_ALL_SOURCES'))
actual entry point: org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler#createSecurityExpressionRoot
@cherniag
cherniag / Elasticsearch
Last active November 1, 2017 12:45
Elasticsearch
1. Create index
curl -X PUT "http://<>:9200/index-name" -d '{
"mappings": {
"record": {
"properties": {
"actionStartedOn": {
"type": "date"
},
"rddCount": {
"type": "long"
@cherniag
cherniag / impala
Last active January 24, 2017 18:35
impala
1.Import csv file to hdfs:
export HADOOP_USER_NAME=impala
./hadoop fs -put /Users/gennadii/dev/performance_impala.csv hdfs://<host>:<port>/user/impala/performance_impala.csv
2.Create IDEA datasource Impala using Impala JDBC driver (all jars in zip)
3.Create connection
jdbc:impala://<host>:<port>
4.Create table (the same name as file):
@cherniag
cherniag / startup
Created December 28, 2016 15:19
Spring Boot
org.springframework.boot.BeanDefinitionLoader
parse @Config classes:
org.springframework.context.support.AbstractApplicationContext#refresh ->
org.springframework.context.support.AbstractApplicationContext#invokeBeanFactoryPostProcessors ->
org.springframework.context.annotation.ConfigurationClassPostProcessor#postProcessBeanDefinitionRegistry ->
org.springframework.context.annotation.ConfigurationClassPostProcessor#processConfigBeanDefinitions ->
org.springframework.context.annotation.ConfigurationClassParser#parse
@cherniag
cherniag / transaction listener
Created August 31, 2016 09:50
transaction listener
TransactionSynchronizationManager.registerSynchronization(
new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
fireAfterSaveEvent(oldSourceFinal, updatedSource);
}
}
);
@cherniag
cherniag / java tools
Created August 1, 2016 12:33
java tools
sudo /usr/java/jdk1.8.0_60/bin/jstack -F -m 29186
print stacktrace for every thread, -m includes native
sudo /usr/java/jdk1.8.0_60/bin/jmap -histo:live 29186
prints histogram of java objects
@cherniag
cherniag / eclipselink
Last active January 4, 2017 12:34
Eclipselink notes
@cherniag
cherniag / _flow
Created June 13, 2016 15:41
spring security
org.springframework.web.filter.DelegatingFilterProxy#doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
if (delegateToUse == null)
WebApplicationContext wac = findWebApplicationContext()
delegate = wac.getBean("springSecurityFilterChain, Filter.class)
org.springframework.web.filter.DelegatingFilterProxy#invokeDelegate(delegate, request, response, filterChain)
delegate.doFilter(request, response, filterChain)
org.springframework.security.web.FilterChainProxy#doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
org.springframework.security.web.FilterChainProxy#doFilterInternal(ServletRequest request, ServletResponse response, FilterChain chain)
List<Filter> filters = getFilters(fwRequest)
for (SecurityFilterChain chain : filterChains)