On line 24 I get the warning: Contents of StringBuilder 'replacement' are updated, but never queried
On line 26 I get the warning: Result of 'String.replaceAll()' is ignored
Why?
package com.codegym.task.task25.task2511;
import java.util.TimerTask;
/*
Arming ourselves to the teeth!
*/
public class Solution extends TimerTask {
protected TimerTask original;
protected final Thread.UncaughtExceptionHandler handler;
public Solution(TimerTask original) {
if (original == null) {
throw new NullPointerException();
}
this.original = original;
this.handler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
String s = e.getMessage();
String name = t.getName();
StringBuilder replacement = new StringBuilder();
for (int i = 0; i < name.length(); i++) replacement.append("*");
s.replaceAll(t.getName(), replacement.toString());
System.out.println(s);
}
}; // Init handler here
}
public void run() {
try {
original.run();
} catch (Throwable cause) {
Thread currentThread = Thread.currentThread();
handler.uncaughtException(currentThread, new Exception("Blah " + currentThread.getName() + " blah-blah-blah", cause));
}
}
public long scheduledExecutionTime() {
return original.scheduledExecutionTime();
}
public boolean cancel() {
return original.cancel();
}
public static void main(String[] args) {
}
}