Ties
03/07/2022, 4:22 PMPathVariable
@RestController
class MyController {
@JvmInline
value class Positive(val value: Int) {
init { require(value > 0) }
operator fun plus(other : Positive) = Positive(this.value + other.value)
}
@GetMapping("/{id}")
fun getTypeWithId(@PathVariable("id") id : Positive) : ResponseEntity<Positive>{
println(id)
return ResponseEntity.ok(id)
}
}
Turns out, if I send a request with the value -1
it will actually print and return -1
, so I just managed to create a Positive negative value ๐
So it compiles, and it seems that jackson is ignoring the require
when creating a value class. (I am aware that this is not Arrows fault, just wanted to share)Emil Kantis
03/07/2022, 4:38 PMSam
03/07/2022, 4:38 PMTies
03/07/2022, 4:52 PMEmil Kantis
03/07/2022, 4:53 PMTies
03/07/2022, 4:53 PMAlejandro Serrano Mena
03/12/2022, 8:02 PM