Skip to content
Advertisement

Tag: spring

Connecting to ES with Spring Data Elasticsearch (reactive) gives error host not reachable

I’m running on an aws-elasticsearch (with OpenSearch 1.1.x) service and im trying to connect with it from a spring application using spring-data-elasticsearch, according to the doc i configured the bean as it says. on my local i used a ssh tunnel from my aws account. i used this command: so i can connect with OpenSearch dashboard over localhost in my

Checking if an object exists in a list Java Stream

I have 2 entity. One of them User, and the other one is Followers. I’m trying to make a follower system like Twitter. User can follow another user but, i want to check if user followed, don’t do it again. This is my Follower Entity : And this is the Service class : As you can see, I got the

How to handle blob store url when receive from API

I have an API URL (e.g.: localhost:8080/api/blobs/download/{item-id}). The API itself will return the URL of that item in the Blob Store (for example, https://myaccount.blob.core.windows.net/mycontainer/myitem). Now I have a task that requires user to copy and paste the API URL into the browser, and expect it to view/download the item. The question is how Java can support user browse the Blob

Convert Flux into Flux

I am working on spring webflux file upload. From the controller I want to upload the file on amazon S3 bucket. So in the controller I received following object And from the FilePart.content() I can get My question is how can I convert this Flux<DataBuffer> into Flux<ByteBuffer>. I mean into the following object Answer You can simply use the org.springframework.core.io.buffer.DataBuffer#asByteBuffer():

count non-null numbers of an object

I am making a method that can count non null value of an object, but I have an object inside another object and I have to confirm if that object is empty too, I tried with isEmpty, isNull but it says it is not empty. Object Validation method I have also tried with !ObjectUtils.isNull… Even though the “result” object has

How to mock factory method in service test with mockito

Hi I am trying to test service layer. I have already wrote tests for ConverterFactory. I think I need the mock dependency classes which ConverterServiceImpl using but Still I got NullPointerException This is my service class And this is the test This code throws error says. What am i doing wrong here?: Answer You don’t need to create a ConverterFactory

Spring Security Expression: “authenticated” vs. “isAuthenticated()”

According to the Spring Security docs, the expression to check whether a user is authenticated is isAuthenticated(). So we would do @PreAuthorize(“isAuthenticated()”), for example. However, according to the official example and confirmed by my own testing, @PreAuthorize(“authenticated”) also works. Is it a Spring Security feature or perhaps simply a Java feature (e.g. authenticated is the field that backs the getter

Advertisement