You can configure a memory health check in Helidon SE. A memory health check will return a status of UP
if the memory usage is below a certain threshold percentage and DOWN
if the memory usage is above the threshold percentage. The default threshold percentage is 98%
. To add the memory health check you need to add the dependency io.helidon.health:helidon-health-checks
to your pom.xml
file. This dependency contains three health checks: disk space usage, memory usage and dead lock detection.
To configure the memory health check you need to set the configuration property server.features.observe.observers.health.helidon.health.memory.thresholdPercent
to the threshold percentage. Alternatively you can set the threshold percentage in your application code.
Continue reading →
Suppose you want to return a response based on the Accept
header of the request. If the Accept
header is application/json
you want to return a JSON response and if the Accept
header is application/xml
you want to return an XML response. You can use the isAccepted(MediaType)
of the ServerRequestHeaders
class to check if the value of the request header Accept
is equal to the specified media type. The method returns true
if the media type is defined for the request header Accept
and false
if not.
In order to convert an object to XML you need to add the dependency com.fasterxml.jackson.dataformat:jackson-dataformat-xml
to your pom.xml
file:
Continue reading →
You can write an implementation of the interface EnvironmentPostProcessor
to customize the Environment
of a Spring Boot application. For example you can read an external configuration file and add its properties to the Environment
. If you want to add some logging statement to the class then you need to make sure you pass a DeferredLogFactory
to the constructor of the class. From this factory you can use the getLogger
method to get a Log
instance. This is needed, because the implementation of the interface EnvironmentPostProcessor
is created before the logging system is initialized. By using the Log
instances created from DeferredLogFactory
Spring Boot will make sure the log messages are written when the logging system is initialized.
Continue reading →
In Helidon SE you can enable a health check for the disk space usage. If the disk space usage is above a certain threshold then the health check will fail. To enable the disk space health check you need to add the dependency io.helidon.health:helidon-health-checks
to your pom.xml
file. The dependency contains three health checks: disk space usage, memory usage and dead lock detection.
To configure the disk space health check you need to set the configuration property server.features.observe.observers.health.helidon.health.diskSpace.thresholdPercent
to the threshold percentage. Or programmatically set the value in your application code. The default value is 99.999
, which means that in real life the health check will not fail. You need to set a lower percentage in order to see the health check fail. For example when you set the value to 95.0
then the health check will fail when the disk space usage is above 95% or less than 5% of the disk space is available. You can also configure the path to check for disk space usage. The default path is the current working directory, but it can be set to another path. You need to set the configuration property server.features.observe.observers.health.helidon.health.diskSpace.path
to change the path.
Continue reading →
With Helidon SE you can add a health endpoint to your application by simply adding a dependency. In your pom.xml
you have to add the dependency io.helidon.webserver.observe:helidon-webserver-observe-health
. This adds a new endpoint /health
to your application. When your application is up and running the /health
endpoint will return the HTTP status code 204 with an empty body. If your application is not healthy then the HTTP status code 503 is returned. In case of an error an HTTP status code 500 is sent to the client.
If you want to see a response with details then you need to set the configuration property server.features.observe.observers.health.details
to the value true
. Instead of the HTTP status code 204 the status code 200 is returned when our application is healthy. The response contains a JSON object with a status
field with the value UP
for a healthy response. The response also contains the field checks
with an array of detailed information from health checks that are available in our application.
Continue reading →
Hibernate is a great Object Relational Mapping (ORM) library for accessing data in a relational database.
It is one of the leading implementations of Java Persistence (formerly known as JPA).
Using JPQL (based on HQL,
which is still a nice syntax guide) one can access and update the data in the database through your ORM objects in a simplified SQL way.
However, when implemented incorrectly one can run into serious performance problems.
They can all be avoided though.
Here are some important things to consider to make your queries performant.
Continue reading →
It’s the year 2023.
JDriven colleagues have gathered to discuss the new trends and deprecations of our work to put on the latest TechRadar.
Once everybody is seated, everyone contributes their latest opinions.
Very soon discussions run high.
Lombok is dropped at the table of discussion as well.
After some debate, it is decided.
Lombok is put on HOLD!
Continue reading →
When developing software I find it very useful to stick to a number of rules.
They are all commonly known, but it can be very convenient to have list of them.
Sticking to these rules will enhance the quality of your code drastically.
Continue reading →
In part 1 of this blog data was exfiltrated from a workstation to GitHub using Git.
In part 2, we’ll dive into investigating the data on a Windows 10 workstation to determine whether any sensitive data was exfiltrated to GitHub using Git.
The investigation focuses on analyzing traces left on the device, excluding network activity logs.
Continue reading →
When Maven needs to download artifacts from a remote repository, it logs the progress of the download. This can lead to a lot of noise in the output. Luckily, we can suppress the logging of the download progress. Since Maven 3.6.1. we can use the command-line option --no-transfer-progress
to disable the logging of the download progress. There is also a short version of the option: -ntp
.
Continue reading →