== How to fix it in Java SE

=== Code examples

include::../../common/fix/code-rationale.adoc[]

==== Noncompliant code example

[source,java,diff-id=1,diff-type=noncompliant]
----
private static final Logger logger = Logger.getLogger("Logger");

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
  
  String data = request.getParameter("data");
  if(data != null){
    logger.log(Level.INFO, "Data: {0} ", data);
  }
}
----

==== Compliant solution

[source,java,diff-id=1,diff-type=compliant]
----
private static final Logger logger = Logger.getLogger("Logger");

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
  
  String data = request.getParameter("data");
  if(data != null){
    data = data.replaceAll("[\n\r]", "_");
    logger.log(Level.INFO, "Data: {0} ", data);
  }
}
----

include::../../common/fix/how-does-this-work.adoc[]
