Mi duda es como puedo solucionar un java.lang.RuntimeException: generado al mapear los datos con Jackson: com.fasterxml.jackson.databind.exc.InvalidFormatException. Debido a que no puede serializar el tipo String "N/A" a interger: Cannot deserialize value of type java.lang.Integer
from String "N/A": not a valid java.lang.Integer
value.
Ese error pasa con las series que no cuentan con un numero de temporadas dentro de los datos del API.
at [Source: (String)"{"Title":"Matrix","Year":"1993","Rated":"N/A","Released":"01 Mar 1993","Runtime":"60 min","Genre":"Action, Drama, Fantasy","Director":"N/A","Writer":"Grenville Case","Actors":"Nick Mancuso, Phillip Jarrett, Carrie-Anne Moss","Plot":"Steven Matrix is one of the underworld's foremost hitmen until his luck runs out, and someone puts a contract out on him. Shot in the forehead by a .22 pistol, Matrix \"dies\" and finds himself in \"The City In Between\", where he is ...","Language":"English","Countr"[truncated 368 chars]; line: 1, column: 845] (through reference chain: com.aluracursos.screenmatch.model.DatosSerie["totalDeTemporadas"])
Ejemplo con la serie Matrix. Ejemplo de resultados del API para serie Matrix en postman ]
Que archivos debería modificar, que código sostiene las mejores practicas para solventar ese error. Log del Error:
Por favor escribe el nombre de la serie que deseas buscar
matriz
2024-05-11T23:52:46.797-05:00 INFO 20416 --- [screenmatch] [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-05-11T23:52:46.829-05:00 ERROR 20416 --- [screenmatch] [ main] o.s.boot.SpringApplication : Application run failed
java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Integer` from String "N/A": not a valid `java.lang.Integer` value
at [Source: (String)"{"Title":"Matriz","Year":"2023–","Rated":"N/A","Released":"N/A","Runtime":"N/A","Genre":"Drama","Director":"N/A","Writer":"N/A","Actors":"Paula Foncea, Vicente Vergara, Farah Hamed","Plot":"N/A","Language":"Spanish","Country":"Spain","Awards":"1 win & 17 nominations","Poster":"https://m.media-amazon.com/images/M/MV5BMTFiYjgzNzUtZTJmZC00NzVjLWExMjMtYjQ1YTE1ZDY2MTgzXkEyXkFqcGdeQXVyMTEwNTc0Mzkw._V1_SX300.jpg","Ratings":[],"Metascore":"N/A","imdbRating":"N/A","imdbVotes":"N/A","imdbID":"tt14404586","[truncated 55 chars]; line: 1, column: 532] (through reference chain: com.aluracursos.screenmatch.model.DatosSerie["totalDeTemporadas"])
at com.aluracursos.screenmatch.service.ConvierteDatos.obtenerDatos(ConvierteDatos.java:14) ~[classes/:na]
at com.aluracursos.screenmatch.principal.Principal.muestraElMenu(Principal.java:28) ~[classes/:na]
at com.aluracursos.screenmatch.ScreenmatchApplication.run(ScreenmatchApplication.java:19) ~[classes/:na]
at org.springframework.boot.SpringApplication.lambda$callRunner$5(SpringApplication.java:790) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:83) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:88) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:789) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.lambda$callRunners$3(SpringApplication.java:774) ~[spring-boot-3.2.5.jar:3.2.5]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774) ~[spring-boot-3.2.5.jar:3.2.5]