Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could java.io.RandomAccessFile.readBytes blocking calls be acceptable in reactive application? In which cases?

We have an application utilizing Spring WebFlux which uses Project Reactor. I ran BlockHound evaluation for the application and it reported java.io.RandomAccessFile.readBytes blocking calls in such libraries like hibernate-validator, orika mapper. hibernate-validator reads error messages from its ValidationMessages.properties file. How severe is the negative impact of this blocking call (that just read a message from property file) for a reactive application? Could it be ignored or should we find the non-blocking solution for this validation?

like image 829
Vera Ratkevich Avatar asked May 08 '26 19:05

Vera Ratkevich


1 Answers

Unfortunately there's no quick answer here - it depends, you'd have to look at the use of RandomAccessFile.readByte() in each library, and deem if it's acceptable or not.

In general:

  • If it's just being used at startup - no problem, as this will then happen outside of any event loop in place;
  • If it might happen at some point in the event loop, then that's absolutely an issue that you need to work around.

If hibernate-validator is genuinely only using this to read a properties file, then this likely falls under the first category so isn't an issue. I would be cautious of that however, as it seems a bit odd that a properties file is being loaded as a RandomAccessFile, they're usually read sequentially - so I'd at least double-check that to make sure it's what's really happening.

like image 70
Michael Berry Avatar answered May 11 '26 15:05

Michael Berry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!