[decorators] fixed URLAsResourceName when the cast fails

This commit is contained in:
Emanuele Palazzetti 2017-08-04 12:45:52 +02:00
parent 2f383e667f
commit abbb441270
No known key found for this signature in database
GPG Key ID: F4D8F69FEF18A502
1 changed files with 20 additions and 22 deletions

View File

@ -44,10 +44,12 @@ public class URLAsResourceName extends AbstractDecorator {
@Override
public boolean afterSetTag(final DDSpanContext context, final String tag, final Object value) {
try {
final String statusCode = (String) context.getTags().get(Tags.HTTP_STATUS.getKey());
final String statusCode = String.valueOf(context.getTags().get(Tags.HTTP_STATUS.getKey()));
// do nothing if the status code is already set and equals to 404.
// TODO: it assumes that Status404Decorator is active. If it's not, it will lead to unexpected behaviors
if (statusCode != null && statusCode.equals("404")) {
return true;
}
// Get the path without host:port
String path = String.valueOf(value);
@ -66,12 +68,8 @@ public class URLAsResourceName extends AbstractDecorator {
path = verb + " " + path;
}
//Assign resource name
context.setResourceName(path);
}
} catch (final Throwable e) {
return false;
}
return true;