~/devreads

Paweł Chudzik

https://blog.pchudzik.com/ · 73 posts · history since 2016 · active

26 Sept 2022

1 min read

Not all docker images are available for ARM architecture (hopefully this will improve over time). Right now I’m working on a project where images for ARM are not available. Emulation works ok (but slow) most of the time. Lately, I stumbled upon an interesting performance/startup issue when running amd64-based containers using testcontainers in an integration test. Read more

12 May 2022

1 min read

I have two GitLab accounts - "work account" and "personal account". One is for my professional work, it is registered to my work email. The second account is for my private/learning projects registered with my private email address. I want to keep those things separate and use two different identities when working with git. Lately, I’ve bought a new computer…

23 Jan 2022

1 min read

Using Gson in your e2e tests might result in tests passing even when contract is broken. Gson is quite imprecise when it comes to deserializing objects from json. Is there any difference between an enum and a string? Is there any difference between s string and a number? Using Java you might answer: sure there is. Even when talking about…

7 May 2020

1 min read

The circuit breaker is a communication pattern that helps to avoid cascading failure of the system and gives dependent services time to recover. Along with fallback values defined by the developer, it gives a pretty wide safe net when communication channel is broken. Read more

23 Apr 2020

1 min read

Real-life OpenAPI specification files tend to go really big really fast. In this post, I’ll try to explore how we can split single specification file into multiple files and don’t get crazy while scrolling up and down like a mad man. Read more

15 Apr 2020

1 min read

Collections are an important part of every programming language. In python, there is a couple of built-in collections like list, set, dictionary but I’m not going to dig into them now. In this post, I’ll explore what it takes to implement collection like objects on your own using collections protocol. Read more

25 Mar 2020

1 min read

Working with python is fun (as with any language you get hooked up on). You can write simple scripts with it, or complex programs and utilities. The most surprising thing for people coming from the java world might be that in this "scripting" language everything is an object. In this post, I’ll explore basic protocols available for user-defined objects. Read…

17 Mar 2020

1 min read

The simplest possible strategy that can help with communication issues is retrying to execute the request again. Maybe it was just a network glitch and it will work just fine when you try to call it again. Introducing retries is a relatively simple step that can improve the stability of your service. But before adding retries check if you’ll not…

28 Feb 2020

1 min read

At work, we are splitting the monolithic application into smaller services. From time to time we have some challenges in doing it the right way. Lately, most of the splitting is focused on cutting out frontends to be outside of the monolith. It gives solid results as we are getting logic and business rules in one place. The downside is…

14 Feb 2020

1 min read

In this post, I’d like to show you how I’ve started with writing this blog. How the process evolved during 3 years of writing. How I’ve finally managed to set up everything in a way that works for me now. If you don’t blog yet this might help you out with technical details on how you can start easily. If…

20 Jan 2020

1 min read

When I’ve first learned that there is something more than printing things to console log4j was state of the art solution. Then SLF4J joined the party and improved where log4j was lacking. The new version of LOG4J is available for some time already and I didn’t have a chance to look at what if offers. Let’s examine what’s possible with…

9 Jan 2020

1 min read

Sometimes it’s good to have an option to try something out on the live environment. Checking things against production like traffic is the most reliable way to gather real-life metrics. In this post, I’m going to try and set up spring cache with a toggle. It’ll be possible to turn it off and on during application runtime possibly using external…

27 Dec 2019

1 min read

On almost every job interview there are questions about frameworks, programming principles, maybe some coding or whiteboard architecting. On the other side, there is the way you work. Tools and skills you use on a daily basis which define how you work. No one really asks about those things but I find them quite important. Read more

12 Dec 2019

1 min read

At work, we are slowly breaking down the monolithic application into smaller manageable services. Some time ago we had a very interesting issue which proved that microservices are hard to implement. It’s especially true if you are not there yet but somewhere in the middle. When you need to introduce intermediate solutions which will enable you to work further on…

27 Nov 2019

1 min read

Some time ago we had a problem with performance caused by generating big reports for users. During one of the firehouse meetings, there was an idea to generate reports from the replica database. We’ve solved the issue differently but the idea got me interested. In this post, I’ll configure spring-boot based application to use the replica database for all read-only…

11 Nov 2019

1 min read

You probably already know that by default in spring transactions are rolled back only for runtime exceptions. When a checked exception is thrown from your code and you don’t explicitly tell spring that it should rollback the transaction then it get’s committed. In this post, I’m going to create simple reference material on when transactions are rollback when using Spring…

24 Oct 2019

1 min read

One thing that a lot of people hate to do is writing documentation. Usually, it’s postponed until development is finished and once it’s done there is rarely time to do it properly. If you get past the struggle of writing it down there is always a problem of keeping it up to date. To avoid those pain points I’m going…

10 Oct 2019

1 min read

If you are not working with multithreading programming and don’t have to test any asynchronous code then this post will probably do you nothing good. But if you have ever struggled with testing some logic running in multiple threads and you don’t know Awaitility. A small library helps testing asynchronous code. If you’ve never heard of it then you should…

22 Sept 2019

1 min read

Mocking library is an important tool in every developer toolbox. Sometimes you want to do things that at first glance look a bit more complex than returning number 42 from some method. Let’s see what stubbing techniques are available in Mockito out of the box and what they offer. Read more

11 Sept 2019

1 min read

We are improving cache in the project Im working on. In the code base I’ve found a method which accepted a collection of ids and returned collection of objects for those ids. My goal was to add cache on individual values returned by the method. Creation of items was IO heavy and time-consuming operation so removal of cache was not…

22 Aug 2019

1 min read

In the past, I’ve implemented couple of tests that aimed to verify naming conventions or some other practices team agreed upon. And presented a way how to ensure they are followed. When I’ve been writing those I was not aware that there is a library that aims to test architecture conventions - ArchUnit in this post I’ll write a simple…

13 Aug 2019

1 min read

I’m learning python for some time now. I’ve made myself familiar with the syntax and then started looking into other ways to increase my knowledge about language and learn its quirks. I’ve found a very nice site that allows me to practice basics and strengthen different kind of muscles that I’m using in my day job - adventofcode. Read more

18 Jul 2019

1 min read

Recently I’ve found a very interesting project which allows to spin up docker containers for test purposes. Writing tests checking integration with external services is not an easy task. With testcontainers library it gets simpler because you can have external service up and running just for your test in a couple of lines of code. Read more

11 Jul 2019

1 min read

Recently I had to set up some extra logic to be executed before running tests. I had two options - create yet another abstract class with some behavior or somehow extend Spock and introduce extra logic to be executed just before actual test starts. As we already have enough of abstract classes I decided to try and do the second…

27 Jun 2019

1 min read

When the whole team agrees on coding standards we tend to be optimistic. We think that from now on everything will be exactly as we decided. The truth is that usually after a couple of months you’ll reinstall IDE or system and forget about configuration or new people join and it’s the Wild West all over again. Read more

13 Jun 2019

1 min read

Spring provides many easy to use abstractions and you use many of them without even knowing about them. You probably know that in order to have @Transactional or @Cacheable annotation work spring creates proxies for you (sometimes proxies on top of proxies…​), but have you ever wondered how it’s happening under the hood? What Creation of object proxies is a…

29 May 2019

1 min read

Version management in maven (especially in multi-module projects) was not pleasant and required multiple build steps, some magic commands and maybe bash script here and there. With version 3.5.0 new cool feature has been added to maven. From this version you can easily customize your build number from build tools using simple properties like ${revision} ${sha1} and ${changelist}. Read more

10 May 2019

1 min read

In the past, I’ve been doing various things with maven. Some of them were standard, some were more complicated and a couple of them were complex. For those complex solutions, I felt like I needed a plugin but I’ve never had enough time to write it properly. In this post, I’m going to explore the basics of writing maven plugin.…

29 Apr 2019

1 min read

How beans are registered in spring and what is the base of beans creation, how to extend spring’s context to our needs? In this post, I’m going to dig into the foundation of many mechanics in spring framework - bean definition. Read more

11 Apr 2019

1 min read

Some time ago I’ve faced a very interesting support issue. Long story short it turned out that one of our applications was not connecting to proper service and as a result, it’s been displaying invalid data to users. After a bit of investigation, I’ve noticed that spring’s configuration mechanism did fallback to default value because of missing configuration key for…

28 Mar 2019

1 min read

Have you ever wondered how it’s possible that spring-boot is able to pick up whatever you have on the classpath and configure application context to your needs based on some conventions and bit of black magic? In this post, I’m going to dig into spring.factories file on which most of the spring-boot power is based. Read more

14 Mar 2019

1 min read

How to introduce automated checks that will guarantee that conventions are followed in an example of test naming convention. I’m going to focus on creating automated process that will verify if test names do match conventions. Automation will allow us to forget about the rule because the computer will ensure it’s followed. Test that I’m going to introduce will be…

20 Feb 2019

1 min read

Have you ever wondered how spring does things? How field annotated with @Autowired is populated? How asynchronous or scheduled methods are discovered. In this post, I’m going to take a deeper look and scratch a bit on the surface of spring internals. I’ll focus on BeanPostProcessor interface which can be used to achieve interesting things and is used in many…

6 Feb 2019

1 min read

I’ve been working with gradle for some time but I’ve never needed to configure deployment from gradle to maven repository. In this post, I’m going to configure deployment of java based gradle project to the nexus artifact repository. This will include uploading a signed jar itself with javadoc and sources. Read more

22 Jan 2019

1 min read

Some time ago I’ve started working on updating automated tests written in selenium with java. After working a bit with it I’ve noticed that from time to time constructing XPath expression can get ugly. We are writing our tests in pure java and "ugliness" usually comes from string concatenation when some extra parameters must be taken into account. I’ve decided…

10 Jan 2019

1 min read

At work I’m are engaged in the maintenance and development of a pretty big legacy monolithic application. Some time ago team size basically doubled. To keep things simple and activate more people we decided that we need to split the huge team into smaller more focused parties. Here is how we are working on many features of the same code…

18 Apr 2018

1 min read

Managing and versioning a bunch of connected libraries or services is hard. It doesn’t matter if you are a consumer or a provider of it. In this post, I’m exploring two simple solutions which might come in handy if you develop an ecosystem of libraries/services or when you are a consumer of those. It is all about semantic versioning and…

20 Mar 2018

1 min read

While deep diving into the code I very often see people struggle when testing random changing/things. There is a really simple solution for this and in this blog post, I’m going to show you "one simple trick" that will fix this problem. Read more

27 Feb 2018

1 min read

At work and in my private time I’m trying to get myself familiar with AWS cloud. Almost all of this is new for me. I know how to setup few things using AWS web console but infrastructure as a code was calling to me and I wanted to give it a spin. My first task was to create VPC with…

15 Feb 2018

1 min read

In my free time, I’m trying to learn something new and best of way learning is by doing. To avoid spinning my wheels in vain I’m helping to develop some product. In the previous post, I’ve described what we’ve decided to use for the UI and pointed out that I’m going to write integration tests. Here is how I integrated…

30 Jan 2018

1 min read

Most of java web applications is built on top of the Spring Framework. Spring has pretty good support for testing and it is a mistake not to take advantage of features it offers. I’ve been developing various applications using Spring MVC for some time and I’ve noticed few patterns for testing that do work. Read more

23 Jan 2018

1 min read

While working on private stuff I’ve encountered a moment when I was in need to create a web-based user interface for the application I’ve been developing lately. In this post, I’m going to briefly describe why I’ve decided to use Node.js for generating HTML on the server side and how I’ve taken advantage of the javascript on the server side…

9 Jan 2018

1 min read

If because of reasons you have to run Maria/Postgres/Oracle on localhost for development and you often import database dumps into it you probably spend some time waiting for DB to be ready to use. In this post, I’m going to show you how you can automate the whole process and save some time doing it with docker. Read more

21 Dec 2017

1 min read

It all started on Friday, like many of the bad things that can happen in software ;) We’ve been working for some time and after being blocked with deployments for a long time (don’t ask, you don’t want to know ;)) we were finally able to deploy a new version. Our last release was about week ago. Do the deployment…

7 Dec 2017

1 min read

Imagine the situation when you’ve just released something on production and deployment went fine. You’ve just sent release notes and went out to grab a coffee. Once you are back you see an email with information that feature team have been working on for past 3 sprints doesn’t work at all. Turns out you forgot to change something in production…

29 Nov 2017

1 min read

Recently while starting work on a project we’ve (team of two ;)) decided to try something new and use Kotlin. The project is far from ready and still under active development, but after writing some code in Kotlin I’ve got few observations I’d like to share. Read more

10 Nov 2017

1 min read

The story is really simple. I wanted to accept my class as rest controller method param. I decided that I don’t want to convert a simple string to object every time and it would be faster if I do the conversion in the single place. After a quick research I’ve found Converter interface which looked like perfect for the job.…

31 Oct 2017

1 min read

Most of the application we are working on are built around the data. Since the information is the core value of the application we store it in the persistent and reliable storage - database. Applications evolve in time so does the way we store the data. In this post, I’m going to present my experiences and thoughts on evolving database…

16 Oct 2017

1 min read

While investigating @EventListeners in spring I’ve noticed very interesting annotation - @DomainEvents. In this post I’m going to check what can be achieved using @DomainEvents annotation and how to effectively use it with old good JPA. Let’s start with short introduction to domain event idea if you are not yet familiar with it. Now let’s go back to the @DomainEvents…

9 Oct 2017

1 min read

I do like to write tests in Spock. I’m not sure if I know every feature available but until lately I felt comfortable with my knowledge. Obviously, I should not. There is always something that can catch you off guard. The question is how long will it take to figure out what’s happen. Read more

29 Sept 2017

1 min read

Last time I wrote about events in a spring based application I’ve introduced some basics on how events can be dispatched using spring infrastructure. In this post, I’m going to dig deeper into an order of handlers, exceptions and asynchronous events handlers. Read more

19 Sept 2017

1 min read

At some point in your career, you will not be happy with just a job, you’ll be looking for something which will keep you interested and will sharpen your skills. Lately, I’ve been looking for something new to do. Since I got burned last time I’ve jumped ships I decided it is the time to prepare a list of the…

6 Sept 2017

1 min read

When I’ve got some free time I try to add new features to springmock. Lately, after adding some new stuff I realized that double definition parsing class has more than one responsibility (class parsing, naming, definition creation, etc). So I’ve decided it’s time to refactor it and split responsibilities into dedicated classes. Once I did that and tests in the…

29 Aug 2017

1 min read

Code review is a great process which gradually improves code quality. It is a system you can implement in many ways. In this post I’m going to grumble about one particular way of performing code reviews - when there is only one person responsible for doing code reviews and suggesting/accepting/rejecting changes. Read more

15 Aug 2017

1 min read

We all know how inheritance works and implemented some kind of class hierarchy at least few times during our career. Some of us know already that inheritance is not the silver bullet. Some of us know that inheritance must not be overused and considered with caution. Now I’m going to show you how choosing the quick win might cost you…

1 Aug 2017

1 min read

With spring 4.2 (released more than one year ago) serious improvements regarding embedded events were made. You probably already know it, but I’ve never had a chance to properly investigate it. Lately, when digging into code base of the system I’m currently working on I got an opportunity to see it in action and after quick glimpse, I decided to…

25 Jul 2017

1 min read

I’ve been using springboot for some time now, but there was that one thing that bugged me a lot. While writing integration tests with mocks you are forced to use mockito as the mocking library. That’s great and easy to understand if you are not using spock. The problem is that in spock there are better ways to mock stuff…​…

18 Jul 2017

1 min read

I left the company for which I’ve been working for last 4 years and now it is time to summarize my experiences. It is not the story of shady business nor confession of my sins (not all of it anyway), but rather my thoughts and experiences on working for a long time in the same company from which most of…

11 Jul 2017

1 min read

Some time ago I’ve been struggling with mapping hierarchical data structure in angular. Labels hierarchy was complex (like 4 levels deep with multiple parents, multiple children, basically graph like structure with some logic behind it). In the end it was/is still working but that’s the best I can say about it. Read more

27 Jun 2017

1 min read

We all love to write new stuff and learn about things. But when we’ve got to do something in one of the older applications we’d rather avoid it and lag as long as possible hoping that someone else will handle it. You shouldn’t be afraid of legacy code (as long it is not ball of mud). You should take the…

13 Jun 2017

1 min read

Some time ago I noticed new library in our code base - Random Beans which as the name suggests is a tool developed to easily create random data and random objects for testing purposes. Unfortunately, we used it in the wrong way. Here’s how we backed up from the random test data to regain control over testing. Read more

31 May 2017

1 min read

Some time ago I’ve been trying to dynamically create spring beans. After fast stackoverflow check I decided to drop it and go with something else. Lately I’ve been trying to implement more complicated bean registration mechanism in which skipping dynamic bean creation wasn’t an option. Here’s how you can create spring beans “from code”. Read more

16 May 2017

1 min read

Working with a lot of data using plain JPA or hibernate or spring-data is possible, it does work and usually, it doesn’t require a lot of extra coding. Starting small is the fastest way of getting things done but you must be aware of few things that might shoot you in the foot. Read more

27 Apr 2017

1 min read

Optimistic locking is concurrency control method that allows to execute multiple transactions simultaneously as long as they don’t interfere which each other. That’s definition from wikipedia. You probably already know that Hibernate supports optimistic locking and all you have to do in order to implement optimistic locking in you app is to add @Version on number or timestamp field and…

15 Apr 2017

1 min read

Immutability and functional programming are hot right now. But how to achieve immutability with objects deserialized from json? Luckily there is pretty old feature introduced in jackson 2.7.0 which uses constructor based object creation and uses @ConstructorProperties (introduced in java7). Read more

30 Mar 2017

1 min read

Every codebase depends on multiple external libraries. It is a good idea to stay up to date with external dependencies. It is important to update all security related stuff and it might be helpful or fun to use latest features. I’m going to share my way of staying up to date with external dependencies in maven, gradle and npm. Read…

23 Feb 2017

1 min read

Page object pattern is common practice when writing automated tests using selenium. It allows to gather all possible operations on the page in one place and hide page implementation details from test case. Page object pattern can be used in the same way for angular directives, react and [put framework name here] components. Read more

14 Jan 2017

1 min read

When the project gets bigger and bigger there should be more and more tests. In the perfect world, all tests should be executed really fast, but life is far from perfect and sometimes some tests are slow. When using Gradle + Spock combination we have few ways of deciding how to group tests. I’m going to explore junit @Category in…

3 Dec 2016

1 min read

Private final field modification is possible and it doesn’t require a lot of work. Since you should not use this mechanism in real life there are cases when it is useful. For example this how is Hibernate using this to hydrate final entity fields. But when using final fields with Hibernate you should be extra careful how you declare them.…

6 Nov 2016

1 min read

A few days ago I’ve stumbled upon SQL query performance issue. Git claims that I was the author so maybe that’s the reason I remember this feature. There was like 3 classes, everything was super easy and super fast all I needed to do was to let Hibernate do its thing. Then time passed, new features were requested, the model…

29 Oct 2016

1 min read

Sometimes when unit tests setup is complex we are tempted to take shortcuts and write single setup for all tests which will save as few keystrokes. In the time of writing the test it might feel like a good idea to configure complex unit test setup and reuse it in all test. This way we avoid code duplication and we…

19 Oct 2016

1 min read

HashCode and equals implementations are hard. Usually, it’s tricky to properly implement hashCode and equals method to fully fulfill contract from Java documentation. I’m going to focus on just one the point from the hashCode contract: whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return…

17 Oct 2016

1 min read

First post. It must be Hello world. I’m going to try and start posting something regularly. I’m Java and javascript so it’s probably will be the main topic of this blog. Sometimes I will try to write something more generic and not language specific. Read more