1
See how my controller is
@PostMapping("/anexo")
public DeferredResult<String> uploadAnexo(@RequestParam("files[]") MultipartFile[] files){
DeferredResult<String> resultado = new DeferredResult<>();
// retorno assíncrono
Thread thread = new Thread(new FotoStorageRunnable(files, resultado));
thread.start();
return resultado;
}
And look at my Thread
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;
public class FotoStorageRunnable implements Runnable {
private MultipartFile[] files;
private DeferredResult<String> resultado;
public FotoStorageRunnable(MultipartFile[] files, DeferredResult<String> resultado) {
this.files = files;
this.resultado = resultado;
}
@Override
public void run() {
System.out.println(">>> files: " + files[0].getSize());
resultado.setResult("ok! esse é o resultado foto recebida");
}
}
This message should have arrived on the server;
System.out.println(">>> files: " + files[0].getSize());
And these messages should have reached the customer;
resultado.setResult("ok! esse é o resultado foto recebida");
Neither of these two messages arrived and still generated this error message just below;
I wonder where it’s wrong?
That’s the explanation of the error message, you’d have a suggestion how to get around it?
– wladyband
The error you are generating is 503, it is a server error.
– wladyband
I just made a new test, I took the line of code that is on line 19, then the message that is on line 20 went to the client, so the problem is on line 19, I would have to know why the variable files is in trouble.
– wladyband
I am following this line of code https://github.com/algaworks/curso-sistemas-web-com-spring-javascript-bootstrap/blob/master/14.4-besting-availabilitye-da-application-buter/brewer/src/mainjava/comalgaworks/brewer/controller/controller/FotosController.java
– wladyband