Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [java]

Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems. Java is currently owned by Oracle, which purchased Sun in 2010.

Filter by
Sorted by
Tagged with
1 vote
4 answers
145 views

I'm working on a Spring Boot application with a VoucherService and VoucherController. I currently have the service method return an ApiResponse<T> directly, like this: @Transactional public ...
Conquer the world's user avatar
7 votes
3 answers
544 views

The Java List<E> interface includes methods, such as add(E) and remove(Object), that work as the names suggest on instances of mutable concrete implementations, such as ArrayList<E> and ...
Ellen Spertus's user avatar
1 vote
1 answer
211 views

I am refactoring my monolithic application, in which the code is organized based on layered architecture. I want to implement Modulith (Modular Monolit) in my app, but I've run into a problem: I haven'...
Ice K's user avatar
  • 31
0 votes
2 answers
142 views

I'll get straight to the point. I want to implement a class structure in Java similar to the one in the image. Am I falling into bad practice with this kind of diamond-shaped interface implementation?...
A. WW's user avatar
  • 11
2 votes
3 answers
636 views

Sometimes, you inherit from a class that defines the semantics of your type (Shape – Ellipse – Circle). Other times, you inherit simply because it's convenient to do so. A superclass may have ...
Sergey Zolotarev's user avatar
1 vote
2 answers
256 views

Suppose you have a panel with a table, which I will call a pane. The table has a toolbar above it, including an edit button. Editing involves showing an editing dialog. It allows the user to edit the ...
Sergey Zolotarev's user avatar
0 votes
2 answers
203 views

I’m refactoring a microservice project where multiple services share the same domain objects. Over time, these objects have diverged across services, causing inconsistencies. To solve this, I plan to ...
Ryley38's user avatar
  • 111
4 votes
2 answers
327 views

Our team of 5 members are managing a microservice architecture that currently includes around 200 Java Spring boot microservices, with approximately 50 new services being added each year. We follow ...
User1254's user avatar
0 votes
3 answers
217 views

Problem: our application allows users to close a form window after certain changes without any confirmation, instead of pressing the Save button. This makes them complain they have to start afresh. We ...
Sergey Zolotarev's user avatar
1 vote
2 answers
207 views

This is how our desktop applications are launched. In this case, it's called DesktopApp (I changed the actual name). As you see, the dependencies are hard-coded, including their versions. In the ...
Sergey Zolotarev's user avatar
0 votes
1 answer
131 views

I am exploring the state-of-the-art methods to create a service that can run and scale in both cloud (container) and on-premise environments. The current version of the software is designed for on-...
Apollo's user avatar
  • 139
0 votes
1 answer
112 views

I'm developing a microservice-based application that processes a high volume of messages. Each message must be handled according to the user’s personal settings and some tenant-specific (customer) ...
GeekChap's user avatar
2 votes
3 answers
265 views

(related: Fetching records matching multiple joined attributes) If Spring Data doesn't allow GET requests to have a body (and it's considered bad practice anyway) curl -X 'GET' \ 'http://localhost:...
Sergey Zolotarev's user avatar
0 votes
2 answers
156 views

I’m designing a system where various “handlers” apply business rules to an object. Initially I had each handler receive the full domain object: // A large domain object with many properties and ...
nicke7117's user avatar
1 vote
5 answers
557 views

Say I have a bunch of classes that imitate cars: SportsCar, Truck, and SUV. All of these classes share some public methods like start() and stop() which they inherit from an abstract class Car. While ...
Ruben Rundström's user avatar
2 votes
2 answers
242 views

I have a complex process implemented in Java Spring microservice. Currently this process is triggered on user request and it is synchronously executed. This often results in a gateway timeout. ...
DimitrijeCiric's user avatar
2 votes
3 answers
181 views

Is it fine for your data models to have a sort of "open-ended" list of properties? For example, you may have some Employee: // getters, setters, annotations are omitted public class Employee ...
Sergey Zolotarev's user avatar
0 votes
1 answer
219 views

I'm building a JavaFX + Spring Boot application using the MVVM pattern. I’m building a generic “wizard” in a JavaFX + Spring Boot MVVM app. A WizardViewModel drives a sequence of steps (STEP_ONE → ...
Billie's user avatar
  • 77
21 votes
5 answers
5k views

I've heard that I should never use Java serialization (Serializable/ObjectInputStream/ObjectOutputStream) because of security. What's the problem?
Stack Exchange Broke The Law's user avatar
2 votes
3 answers
445 views

There's a convention for boolean property accessors to name them like isX(). Does it apply to all boolean returning methods that are not invoked for their useful side effects, like this one? Also, ...
Sergey Zolotarev's user avatar
3 votes
2 answers
494 views

I'm working on a Spring-based micro service project and considering different approaches for handling authentication and authorization. Instead of setting up a dedicated authorization server, I'm ...
GeekChap's user avatar
-1 votes
1 answer
328 views

I would like to refactor some code of a process that must perform a processing. The processing involves several steps, each of which can fail or go well. If successful, it must proceed to the next ...
jordan1982's user avatar
8 votes
7 answers
5k views

We have entities with numeric properties, they are of boxed types (e.g. Integer). Typically, each of those properties has a pair of getters: getInt(), which returns zero on null values, and ...
Sergey Zolotarev's user avatar
1 vote
2 answers
379 views

Let's say I have the following maven projects. UtilsLibrary -- A maven project containing utils. AppA -- A maven project that depends on UtilsLibrary. AppB -- A maven project that depends on ...
davidalayachew's user avatar
1 vote
4 answers
209 views

Due to type erasure, I can't do instanceof T in Java. With that in mind, how do (should) I write, for example, a generic TreeNode (or, more precisely, DefaultMutableTreeNode)? setUserObject() accepts ...
Sergey Zolotarev's user avatar
5 votes
5 answers
975 views

I'm designing a system with different types of components, and I'm trying to decide whether to use polymorphism or instanceof checks for handling type-specific behavior. I see two possible approaches: ...
user avatar
0 votes
2 answers
363 views

Which code style is preferred in Java? final boolean result = isCausedBy(e, ExceptionType1.class) || isCausedBy(e, ExceptionType2.class) || isCausedBy(e, ExceptionType3.class) |...
Andriy Makukha's user avatar
5 votes
4 answers
350 views

Suppose there's a long IO operation that may result in some return value — but doesn't have to. Completion with no return value is different from the operation being pending. Do I have better options ...
Sergey Zolotarev's user avatar
3 votes
1 answer
168 views

I am currently working in a project where we are utilizing kafka as a Message Queue. We have two use cases here, one is to consume the messages in parallel, no ordering of any kind required. And one ...
Akshansh Jain's user avatar
4 votes
4 answers
460 views

Suppose I have a property with an associated getter and setter (the property is not exposed directly) Where should I describe the property? The field javadoc The getter javadoc The setter javadoc ...
Sergey Zolotarev's user avatar
3 votes
4 answers
2k views

I have a stack of custom Row widgets. Each of them is a label with some editComponent (often a JTextComponent). Rows are aware of their previous and next siblings (if a Row has no such sibling, the ...
Sergey Zolotarev's user avatar
4 votes
3 answers
869 views

My SUT class depends on external static state (which generally should be avoided, I know). How do I make sure my tests do not depend on their order of execution? I mean other by introducing some reset(...
Sergey Zolotarev's user avatar
0 votes
2 answers
241 views

I have recently come across a few codebases at work where the previous developers chose to reach the >80% coverage criteria by writing only integration tests with the @SpringBootTest annotation ...
Mary's user avatar
  • 3
3 votes
3 answers
546 views

I am starting a project in Java and ran into the following situation. The application requires a persistence layer for a certain document type. This could be a MySql database, an AWS Dynamo DB ...
Matias Grioni's user avatar
0 votes
1 answer
86 views

I have a foundational metamodel which I have implemented using Java interfaces which I can easily version using major.minor.bugfix. I also have plugins that utilize these libraries to implement these ...
Proud Papa's user avatar
1 vote
4 answers
546 views

In order to make sure methods fail fast under invalid arguments, I usually do validation at the start of a method. If I'm verifying multiple predicates, this leads to a few lines of checkNotNull or ...
EarthTurtle's user avatar
0 votes
2 answers
193 views

The application in question is integrating with BigImportantThing (BIT). Part of our application's job is to provide a better interface, so this is something to resolve within our application. The ...
Mr Redstoner's user avatar
1 vote
1 answer
97 views

Situation: Order Handling in OMS System: In my OMS system, orders are pushed from an online platform with a unique orderId. Since the orderId is generated by the online platform, I cannot make it auto-...
Help out's user avatar
0 votes
0 answers
93 views

I am building an app where I have tenants and each tenant can have multiple users. The users can do multiple things in the application and these functionalities also are kind of independent from each ...
securita's user avatar
2 votes
0 answers
149 views

We know that combining a domain entity, a DTO, and a REST API serialization class into one won't pass code review: @JsonInclude(JsonInclude.Include.NON_NULL) @Data @Builder @Entity @Table(name = "...
sfinja's user avatar
  • 129
3 votes
3 answers
1k views

I read about three-tier architecture and I have a question: I read that in business logic (that is, what is in logic tier) there should be POJO classes, but in most Spring manuals these classes are ...
dude34810's user avatar
0 votes
1 answer
180 views

I have multiple Flutter Android app projects that have different compatibilities of Java. Now, what should I do if I am developing more than one project simultaneously? If the first one uses Java 17, ...
DevQt's user avatar
  • 131
4 votes
5 answers
3k views

I have the following method, which needs to return a List, but exceptions might occur along the way, and I don't want to handle them in my application, mainly because I don't even know how to handle ...
MasterTJ123's user avatar
0 votes
2 answers
603 views

I’m still a Computer Science student, and recently I’ve had to develop a project using the MVC pattern, but without having learned in depth about how it actually works. And it’s not the first time I’...
MasterTJ123's user avatar
2 votes
1 answer
243 views

With the introduction of JEP 358 in Java 14, which provides more informative NullPointerException (NPE) messages, is it advisable to remove existing explicit null checks in cases where the null-check ...
ftb457932's user avatar
2 votes
3 answers
998 views

I've been considering the way to solve this problem for a while, and I'm currently stuck between two options I both feel are suboptimal. Here's an abstract example of what I'm dealing with: I have a ...
pulpicated's user avatar
-2 votes
1 answer
221 views

Some may think I'm kidding, but I'm really stuck on this Suppose you have some UserDao interface that you want to implement What should you call it? Here are a few points I'd like to make I firmly ...
Sergey Zolotarev's user avatar
1 vote
2 answers
346 views

I have a personal project, I want to write a JIT compiler/runtime in Rust (well, the language is not that relevant). I'm thinking about using a technique where the code is interpreted first and then ...
freakish's user avatar
  • 3,085
0 votes
2 answers
316 views

Let's say there is a domain model: @Table(name = "room") @Getter @FieldNameConstants @AllArgsConstructor(onConstructor = @__({@PersistenceCreator})) public class HotelRoom extends ...
叶知泉's user avatar
2 votes
2 answers
293 views

Concrete example : https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/DataInput.html#readFully(byte[],int,int) @throws NullPointerException if {@code b} is {@code null}. is before @...
William's user avatar
  • 131

1
2 3 4 5
101