Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do @Setter and @Getter annotations of lombok can be thread safe?

I have a problem with my class SessionCanal, when I use in a Web Service the attribute "idSession" is changed when multiple requests come in, I want to know if the Setters and Getters can be thread-safe (synchronized them in some way)

@NoArgsConstructor
public class SesionCanal implements Serializable{
    private static final long serialVersionUID = 360569424947712753L;

    @Getter @Setter private String idSesion;
}

Thanks for your help.

like image 413
Hiroshige Cid Hernández Avatar asked Sep 07 '14 05:09

Hiroshige Cid Hernández


1 Answers

You can use:

@Getter(onMethod_={@Synchronized}) @Setter(onMethod_={@Synchronized}) 
private String idSesion;

with Lombok @Synchronized

like image 129
Nolle Avatar answered Sep 20 '22 02:09

Nolle