October 22, 2024
Chicago 12, Melborne City, USA
java

How to create a Tuple2, Tuple3 etc in Java Reactor?

Created this question and answer to help others with quick lookup of how to create a Reactor Tuple, such as reactor.util.function.Tuple2<T1,T2> I couldn’t find any example constructor on the Javadoc for Tuple2 so had to do some more digging. You need to sign in to view this answers

Read More
java

Java program using Clean Architecture, DAO and Repository

I’m developing a simple Java console program to access PostgreSQL database using JDBC. The most inner layers talk to the outer layers by means abstraction (interface and abstract class). My program follows the Clean Architecture and I have the following: domain entity Student.java Course.java repository Repository<T> (interface) StudentRepository (interface) CourseRepository (interface) use case StudentUseCase.java CourseUseCase.java

Read More
java

Parsing hyphenated yaml fields with snakeyaml?

I have a yaml file that looks like this: resource-path: "src/resource" The data class is generated by lombok and has methods getResourcePath and setResourcePath. I’ve checked these by printing out the methods on the class to be sure. When I try to populate that data class I get this error: Unable to find property resource-path

Read More
java

CascadeType.ALL doesn't save the children. the child doesn't get presist and saved

I have three Entity such as following: @Table(name = "input") @Entity @Data public class CreationInputEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) @Column(name = "ID", unique = true, nullable = false, updatable = false) Long id; @OneToOne(cascade=CascadeType.ALL) @JoinColumn(name = "index_id", referencedColumnName = "id") IndexEntity index; } @Table(name = "index") @Entity @Data public class IndexEntity { @Id @GeneratedValue(strategy

Read More
java

A loader as JAR Spring WebFlux reactive with Reactive Repository

We wrote a spring application webflux reactive with ReactiveRepository that we deployed in a cloud run and it works fine launched by a GCP scheduler that call an API REST. Now, our customer ask to reduce costs defining a job cloud run on GCP so we migrate from war to jar in a new Spring

Read More
java

List the Virtual Threads in Java

How do I list all the virtual threads in a JVM? ThreadMXBean.dumpAllThreads(), ThreadMXBean.getAllThreadIds(), ThreadGroup.enumerate(), and Thread.getAllStackTraces() do not return virtual threads. You need to sign in to view this answers

Read More
java

How can I read a text file line by line in java with an indication of the offset and byte limit?

I have a text file of many lines. For example, a file of 10,000 bytes in size. Bytes of the digital signature are added to the file. I can calculate the size of these added bytes (for example, it’s 500 bytes). How do I line by line (without loading the entire file into memory!) read

Read More
java

How to profile CPU cache miss/hit for Java apps?

I want to figure out the performance difference between two Java applications. Both are tree-searching algorithms, but the faster one requires more pointer dereferences with less footprint (by static analysis). I guess, the better performance derives from the better locality – higher CPU cache hit rate. To verify my conjecture I tried to profile CPU

Read More
java

Unable to use instant app if i remove implementation ('app') from dependency of dynamic module?

I want to use One feature of my app as Instant app which needs below dependecy which is increasing the app size to 60MB. implementation ('org.pytorch:pytorch_android_lite:1.13.1') implementation ('org.pytorch:pytorch_android_torchvision_lite:1.13.1') Hence unable to Upload Instant app on playstore since for instant app to upload, size should be 15MB . So i am trying to remove base module

Read More
java

Eureka Service Discovery UnknownHostException

I trying Eureka Service Discovery for the first time and this is the problem I am facing. java.net.UnknownHostException: banking-portal at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567) ~[na:na] at java.base/java.net.Socket.connect(Socket.java:751) ~[na:na] at java.base/java.net.Socket.connect(Socket.java:686) ~[na:an] My Eureka server is running and both of my applications are registered But, while trying to hit the URL "http://banking-portal/accounts/getById/{accountId}"; I am getting the above-mentioned error. Please

Read More