Petre Popescu Dev Blog

1

Getting NullPointerException when using an Enum? Here is how to fix it!

I started working on a technical debt story at my job. I am working on the back-end for a banking application for one of the biggest banks in Romania. This story involved doing some refactoring that will make the application more maintainable and easier to understands. The refactoring, however, managed to baffle me for almost three hours and only after involving the team we managed to solve an error I did not even knew it was possible: NullPointerException when using...

0

Building your SaaS is the easy part

We all dream of building a nice SaaS or website or some tool that will generate recurring revenue with little maintenance. I know I have this dream and maybe one day I will even manage to make it happen, but for now it is only that, a dream. And not because I haven’t tried, but because building the SaaS is the easy part. Convincing people to use it takes more work and a completely different skillset, skills that most software...

0

How to log HTTP Request and Response in Spring Boot

When you are working on complex systems that are built using multiple micro-services, you will need to know the integrations between them, especially when you are accepting user input. I’ve worked most of my career in the banking and payments industry and knowing what was received and what was returned back to the user is not only important for investigating problems, but a requirement for auditing in certain scenarios. And even if you are not legally required, it is extremally...

0

Masking log output in Logback

It is important to make sure that sensitive information does not get logged by your application. Logging is an important tool for troubleshooting your app, however, it can be easy to accidentally log passwords, emails, or other sensitive information. For such scenarios, I created Logmasker, an open-source library that can be used with both Logback and Log4j2 for masking all sorts of sensitive information. Please look at the dedicated page for LogMasker – Log4j and Logback Masking Library. However, because of...

1

Most horror games fail to scare you, and here is why

A long, long time ago… in a galaxy far awa… No, wait, that is something else! A long time ago, when Flash was not only around, but the norm for rich internet content, I was a game developer. I was young, nothing noteworthy was released, and it was only a small part of my journey into the world of programming, but was an important part that shaped me a little. But, even before I started making small Flash games, I...

better_scheduled_jobs_in_spring 0

How to write more stable Scheduled Cron Jobs in Spring

Up until now, I wrote most of my articles for Play Framework, even though I use almost exclusively Spring Boot in my daily job. Well, how about we change things a bit and this time I will be writing about Spring. And what better article than a way to make your code more stable and easier to maintain and debug? So, Spring has a feature that lets you schedule job executions at certain times or at regular intervals. The @Scheduled...

0

Better unit test with JUnit 5 Parameterized Tests

In many situations, you have to write unit tests that are identical, with the exception of the input or possibly the expected value. It is tempting to write the same test multiple times or to write one test with the dynamic part in a loop. JUnit 5, however, offers a better option with the @ParametrizedTest annotation that allows you to have one test, but with different inputs and expected values. Let’s take a look. Importing the library into your project...

0

How to lock entries in the database to avoid double-processing using Update with limit

Many services have some sort of job that gets executed at regular intervals and does some sort of processing or aggregation. In many instances you read data from the database, do the needed calculations and write the result. This is pretty straightforward and normally does not pose any major problems. You have @Scheduled in Spring, Scheduled Tasks in Play or a simple CRON job that gets executed at regular intervals. Everything works fine if you have one instance that does...

0

How I got hundreds of YouTube Subscribers for free

There are websites that would gladly take your money in exchange for YouTube likes or Subscribers. These services always have a free plan, and in this article I will show I managed to trick the service to give me unlimited subscribers without paying and without actually participating in the like/subscribe exchange system that is put in place.