Home » Java

Java

Retry In The Future

Writing asynchronous code in Javascript is relatively easy. // async function let attempt = 1; while (true) { try { const result = await operationThatMayFail(); // it didn't fail return result; } catch (error) { if (attempt >= maxAttempts || error !== 'Retryable') { // either unhandleable, or no further attempts throw error; } } attempt++; await sleep(pauseTime); } This ...

Read More »

REST API Design: Dealing with concurrent updates

java-interview-questions-answers

Concurrency control can be an important part of a REST API, especially if you expect concurrent update requests for the same resource. In this post we will look at different options to avoid lost updates over HTTP. Let’s start with an example request flow, to understand the problem: We start with Alice and Bob requesting the resource /articles/123 from the ...

Read More »

Upload files in Spring Boot application using Commons FileUpload

spring-interview-questions-answers

In our previous post, we saw how to upload a file using the Spring framework’s default implementation for MultipartFile interface. In this post, we will see how we can use the Commons FileUpload library and the wrapper implementation CommonsMultipartFile provided by the Spring framework. Update the pom.xml We will update the maven dependencies to include commons-io and commons-fileupload. We will ...

Read More »

Uploading files in Spring Boot application

spring-interview-questions-answers

Uploading files is one of the most common operations in a web application. In this article we will look at how to upload file from an HTML page and copy it to the file system on the server. Creating a HTML form with file upload option The below HTML code and its corresponding Javascript code creates the HTML form and ...

Read More »

Unit testing private methods

Introduction In this article, I will contemplate the testing of private methods in unit tests. After that, I will propose a way or pattern to do it, if you must. Finally, I will show how you can generate this pattern automatically. And yes, I will also write a takeaway section to know what you have read. Test or not to ...

Read More »

Java Salary Overview – How Much Does Java Development Cost in Different Regions?

Java is a popular programming language that was launched 25 years ago by the Oracle Corporation. It is mainly used for application development and works best for large scale applications, especially for corporations and enterprises. In the present day, it has emerged as one of the most widely used programming languages. If you’re planning to join a Java development team, ...

Read More »

Introduction into GraalVM (Community Edition): Cloud as a Changing Force

1. Introduction The shift towards cloud computing has had a massive impact on every single aspect of the software development process. In particular, the tools and frameworks the developers have had mastered for years suddenly became unfit, or to say it mildly, outdated. To reflect the reality, the whole new family of frameworks and libraries has emerged, collectively called cloud-native. ...

Read More »

Everyone Could Use a Buddy

This is not about Buddy Holly, and while it’s going to cover Big O notation, it’s not about The Big O himself: Roy Orbison. I’d like to share a problem and solution with you. Consider these data structures in Java (other languages are also available): public class Element { private String name; private ElementData someData; private ... // other stuff ...

Read More »