Home » Author Archives: Tomasz Nurkiewicz (page 6)

Author Archives: Tomasz Nurkiewicz

Java EE developer, Scala enthusiast. Enjoying data analysis and visualization. Strongly believes in the power of testing and automation.

Mapping enums done right with @Convert in JPA 2.1

java-interview-questions-answers

If you ever worked with Java enums in JPA you are definitely aware of their limitations and traps. Using enum as a property of your @Entity is often very good choice, however JPA prior to 2.1 didn’t handle them very well. It gave you 2+1 choices: @Enumerated(EnumType.ORDINAL) (default) will map enum values using Enum.ordinal(). Basically first enumerated value will be ...

Read More »

Null safety in Kotlin

jetbrains-kotlin-logo

Kotlin is a statically typed JVM language developed by Jetbrains. It has some good documentation so today I will focus on a tiny part of it – null safety. There are at least couple of approaches to null handling in JVM languages: Java doesn’t go much further than C – every reference (“pointer”) can be null, whether you like it ...

Read More »

Lazy sequences implementation for Java 8

java-logo

I just published LazySeq library on GitHub – result of my Java 8 experiments recently. I hope you will enjoy it. Even if you don’t find it very useful, it’s still a great lesson of functional programming in Java 8 (and in general). Also it’s probably the first community library targeting Java 8! Introduction Lazy sequence is a data structure ...

Read More »

Java 8: CompletableFuture in action

java-logo

After thoroughly exploring CompletableFuture API in Java 8 we are prepared to write a simplistic web crawler. We solved similar problem already using ExecutorCompletionService, Guava ListenableFuture and Scala/Akka. I choose the same problem so that it’s easy to compare approaches and implementation techniques. First we shall define a simple, blocking method to download the contents of a single URL:   ...

Read More »

Java 8: Definitive guide to CompletableFuture

java-logo

Java 8 is coming so it’s time to study new features. While Java 7 and Java 6 were rather minor releases, version 8 will be a big step forward. Maybe even too big? Today I will give you a thorough explanation of new abstraction in JDK 8 – CompletableFuture<T>. As you all know Java 8 will hopefully be released in ...

Read More »

Synchronising Multithreaded Integration Tests revisited

java-interview-questions-answers

I recently stumbled upon an articleSynchronising Multithreaded Integration Tests on Captain Debug’s Blog. That post emphasizes the problem of designing integration tests involving class under test running business logic asynchronously. This contrived example was given (I stripped some comments):               public class ThreadWrapper { public void doWork() { Thread thread = new Thread() { ...

Read More »

Lazy sequences in Scala and Clojure

scala-logo

Lazy sequences (also known as streams) are an interesting functional data structure which you might have never heard of. Basically lazy sequence is a list that is not fully known/computed until you actually use it. Imagine a list that is very expensive to create and you don’t want to compute too much – but still allow clients to consume as ...

Read More »

SiftingAppender: logging different threads to different log files

logback-logo

One novel feature of Logback is SiftingAppender (JavaDoc). In short it’s a proxy appender that creates one child appender per each unique value of a given runtime property. Typically this property is taken from MDC. Here is an example based on the official documentation linked above:               <?xml version="1.0" encoding="UTF-8"?> <configuration> <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"> ...

Read More »

WatchService combined with Akka actors

akka-logo

WatchService is a handy class that can notify you about any file system changes (create/update/delete of file) in a given set of directories. It is described nicely in the official documentation so I won’t write another introduction tutorial. Instead we will try to combine it with Akka to provide fully asynchronous, non-blocking file system changes notification mechanism. And we will ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.