What would you do if you handed over your code to another team for testing and did not receive a response?
Java
How to correctly implement the hashCode and equals methods in a class?
Did your last project involve technologies and solutions typical for high-load systems?
What name should I use when addressing you?
Explain the purpose and features of using the volatile keyword in programming.
Was the Ashan site disabled or closed?
What would you do if your message about a task in the corporate chat remained unanswered?
Who was responsible for the maintenance and support of the distributed data storage system?
In what situations can data loss occur in Kafka?
How is exception handling implemented in applications using the Spring Framework?
public class MoneyTransferService { /** * @param fromAccountId unique identifier of the user transferring funds * @param toAccountId unique identifier of the user receiving funds * @param amount transfer amount. Positive number */ @Transactional public void transferMoney(Long fromAccountId, Long toAccountId, BigDecimal amount) { if (amount.compareTo(BigDecimal.ZERO) <= 0) { throw new RuntimeException("Amount must be +"); } if (fromAccountId.equals(toAccountId)) { throw new RuntimeException("Account can't be the same"); } Long firstId = Math.min(fromAccountId, toAccountId); Long secondId = Math.max(fromAccountId, toAccountId); Account first = accountRepository.findByIdForUpdate(firstId) .orElseThrow(() -> new RuntimeException("Account not found")); Account second = accountRepository.findByIdForUpdate(secondId) .orElseThrow(() -> new RuntimeException("Account not found")); Account from = fromAccountId.equals(firstId) ? first : second; Account to = fromAccountId.equals(firstId) ? second : first; if (from.getBalance().compareTo(amount) < 0) { throw new RuntimeException("Balance is less 0"); } from.setBalance(from.getBalance().subtract(amount)); to.setBalance(from.getBalance().add(amount)); accountRepository.save(to); accountRepository.save(from); } } @Entity @Data public class Account { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private BigDecimal balance; }
How do HashMap and ConcurrentHashMap differ in Java in terms of functionality and usage in multithreaded segments?
Where are partitions distributed?
What formula is used to determine the number of brokers (nodes) when designing a fault-tolerant Kafka cluster?
What elements or features of the internal structure of HashMap cannot be changed after its creation?
How to properly modify an object so that it can be used in a HashMap collection?
What are the main principles of service design to minimize data or resource loss?
Can you give an example of the idea of dependency inversion in software design?
How do garbage collection mechanisms determine objects to be destroyed?
How is teamwork organized in your team and what processes are used to accomplish tasks?