How to make a class’s constructor unit testable when its instantiating a Guice module in it?

I have the below mentioned class in a library module, which the clients will use to interact with database. I have a public constructor that takes a parameter from the user of this library, but the …

Consumer does not read messages from the Kafka topic (Akka Stream Kafka)

We use Akka Stream Kafka for producing and consuming messages and Strimzi Kafka cluster. Here are the versions if matters: com.typesafe.akka:akka-stream-kafka_2.13:2.0.7 com.typesafe.akka:akka-…

Using Streams and StreamSupplier: forEach closes StreamSupplier instead of instance of stream

I am making a obj file loader for an engine that I’m writing and I am trying to use Streams to load vertex index, uvcoord, and normals from this file. The way I intended to do this was to create a new …

How to Iterate list of list of Java Objects using Java 8

How to iterate and get through list of list of objects using Java 8 Also need to get the count of distinct customerIds final List issues = customerIssues.collectList().block(); …

Discrepancies between Java 11 and Java 8 DecimalFormat behaviour

I’ve got a weird issue with Java 11. I’m porting a huge project, and I have some tests which use DecimalFormat failing on the 11 build, but not on the 8 build. DecimalFormat in Java 11 gives me a …

How to round off to the closest 5 minute interval if it is 1 or 2 minutes ahead or behind?

I want to round off an Instant / LocalDateTime to its closest 5 minutes interval in Java. Examples: Suppose the time is: 2021-02-08T19:02:49.594 Expected result: 2021-02-08T19:00:00.000 Suppose the …

How to iterate over MultipartFile array using Java lambda and streams

Below is my code to upload some file attachments to external storage. I would like to know if there is a way to avoid for loop in the below method to iterate over the MultipartFile[] array so that …

Comparator.comparing(…).thenComparing(…) find out which fields did not match

I am trying to compare two objects of same class and the goal is to compare them as well as identify which fields didn’t match. Example of my domain class @Builder(toBuilder=true) class Employee { …

Cant find pattern with Scanner in Java 8

I’m working with Java 8 on eclipse and trying to use regex to detect strings in a file, but I’m not detecting anything. I’ve tested the regex on its own and it successfully match’s strings in the file …

Why use lambda over normal methods?

So suppose my application does lots of repetitive work, for example let’s say my application checks lots of various Lists if they’re empty or not. There are two methods by which I can accomplish this …