Skip to content
Snippets Groups Projects
Commit 84ee9140 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

Retry for KO attributes done by watcher should work now (TANGOARCH-497)

parent ccb917b3
No related branches found
No related tags found
No related merge requests found
package Common.Archiver.Collector;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -12,15 +10,14 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.tango.utils.DevFailedUtils;
import fr.esrf.Tango.DevFailed;
import fr.esrf.TangoDs.Util;
import fr.esrf.tangoatk.core.AttributePolledList;
import fr.esrf.tangoatk.core.ErrorEvent;
import fr.esrf.tangoatk.core.IAttribute;
import fr.esrf.tangoatk.core.IErrorListener;
import fr.soleil.archiving.common.api.tools.ArchivingEvent;
import fr.soleil.archiving.hdbtdb.api.tools.DBTools;
import fr.soleil.archiving.hdbtdb.api.tools.ScalarEvent;
public abstract class ArchiverCollector implements IErrorListener {
......@@ -287,7 +284,7 @@ public abstract class ArchiverCollector implements IErrorListener {
Throwable error = errorEvent.getError();
if (error != null) {
builder.append("\n\tReason: ");
appendErrorToStringBuilder(builder, error);
DBTools.appendErrorToStringBuilder(builder, error);
}
String errorMess = builder.toString();
logger.error(errorMess);
......@@ -304,7 +301,7 @@ public abstract class ArchiverCollector implements IErrorListener {
}
protected void registerErrorMessage(String name, Throwable error) {
registerErrorMessage(name, appendErrorToStringBuilder(new StringBuilder(), error).toString());
registerErrorMessage(name, DBTools.appendErrorToStringBuilder(new StringBuilder(), error).toString());
}
protected void removeErrorMessage(String name) {
......@@ -323,30 +320,4 @@ public abstract class ArchiverCollector implements IErrorListener {
return result;
}
/**
* Appends the stack trace of a {@link Throwable} to a {@link StringBuilder}. If the {@link Throwable} is a
* {@link DevFailed}, this method will append the result of {@link DevFailedUtils#toString(DevFailed)} to the
* {@link StringBuilder} instead of the stack trace.
*
* @param builder The {@link StringBuilder} to which to append the stack trace. If <code>null</code>, a new one will
* be created.
* @param error The {@link Throwable} of which the stack trace must be extracted.
* @return A {@link StringBuilder}, never <code>null</code>.
*/
public static StringBuilder appendErrorToStringBuilder(StringBuilder builder, Throwable error) {
if (builder == null) {
builder = new StringBuilder();
}
if (error != null) {
if (error instanceof DevFailed) {
builder.append(DevFailedUtils.toString((DevFailed) error));
} else {
StringWriter errors = new StringWriter();
error.printStackTrace(new PrintWriter(errors));
builder.append(errors.toString());
}
}
return builder;
}
}
......@@ -132,6 +132,7 @@ import HdbArchiver.HdbArchiver;
import fr.soleil.archiving.common.api.exception.ArchivingException;
import fr.soleil.archiving.common.api.tools.ArchivingEvent;
import fr.soleil.archiving.hdbtdb.api.tools.AttributeLightMode;
import fr.soleil.archiving.hdbtdb.api.tools.DBTools;
import fr.soleil.archiving.hdbtdb.api.tools.LimitedStack;
public abstract class HdbCollector extends ArchiverCollector {
......@@ -219,7 +220,8 @@ public abstract class HdbCollector extends ArchiverCollector {
if (e instanceof ArchivingException) {
throw (ArchivingException) e;
} else {
ArchivingException exception = new ArchivingException(appendErrorToStringBuilder(null, e).toString());
ArchivingException exception = new ArchivingException(DBTools.appendErrorToStringBuilder(null, e)
.toString());
throw exception;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment