Home » Java

Java

Implementing the Proxy Pattern in Java

java-interview-questions-answers

The Proxy Pattern Proxy is a common software design pattern. Wikipedia does a good job describing it like this: [..] In short, a proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes. Use of the proxy can simply be forwarding to the real object, or can ...

Read More »

Things that make Spring boot Awesome!

spring-interview-questions-answers

For every Java developer Hibernate, Spring are everyday terms. Although recently there was an addition to this list of ‘Spring-boot’. Nowadays Spring Boot is one of the most used open source frameworks. Hence if you are a java developer you must know about spring boot. In this tutorial we will cover srping boot features in detials. Spring-boot can be used ...

Read More »

Testing with Hoverfly and Java Part 2: Delays

On the previous post we implemented json and Java based Hoverfly scenarios..Now it’s time to dive deeper and use other Ηoverfly features. A big part of testing has to do with negative scenarios. One of them is delays. Although we always mock a server and we are successful to reproduce erroneous scenarios one thing that is key to simulate in ...

Read More »

The Poison Message SQS Problem

java-interview-questions-answers

AWS’s SQS is a really reliable and performant solution for transporting requests around a system. A couple of years ago, AWS added event sourcing to it, where a Lambda function can be automatically invoked with batches of data from a queue until the queue is empty. There are lots of important considerations in tuning this, but there’s a particular problem ...

Read More »

Quick tip: Referencing other Properties in Spring

spring-interview-questions-answers

In Spring property (or yaml) files we can reference other properties using the ${..} syntax. For example: 1 2 3 external.host=https://api.external.com external.productService=${external.host}/product-service external.orderService=${external.host}/order-service If we now access the external.productService property (e.g. by using the @Value annotation) we will get the value https://api.external.com/product-service. For example: 1 2 @Value("${external.productService}") private String productServiceUrl; // https://api.external.com/product-service This way we can avoid duplication of commonly used values in property ...

Read More »

AWS Glue – Can not create a Path from an empty string

java-interview-questions-answers

1. Overview I was receiving this error while trying to run an AWS Glue job that communicated with a DB2 11 instance: 1 Exception in thread "main" java.lang.IllegalArgumentException: Can not create a Path from an empty string As we know, AWS Glue is a fully managed ETL service that is built on an Apache Spark environment. As such, AWS Glue ...

Read More »

Developing a Simple Service with Spring Boot

spring-interview-questions-answers

In this post, I will demonstrate how to create a simple web service using Spring Boot.  This framework makes it almost effortless to develop web services, so long as the appropriate dependencies are in-place.  In this example, I will create a web service that will read the current temperature from a file and make it available to clients via a ...

Read More »

Keeping the Caller Busy

There are ways we could refactor the displayCart function, but consider a second what the caller is doing each time it wants to use the function. Consider this simple code example: 01 02 03 04 05 06 07 08 09 10 11 12 13 // caller String shoppingCartMessage = displayCart("You have %s", cart.size());   String otherMessage = displayCart("You saved %s", ...

Read More »

Java 8 Base64 Encoding and Decoding (With Examples)

Learn different ways to do base64 encoding and decoding functionality in java and using java 8 api, and also examples using the apache commons-codec. 1. Overview In this article, you’ll learn the different ways to do the base 64 encoding and decoding techniques in java 8 and other alternative libraries such as apache common API utility. Understand the techniques on ...

Read More »