Merge pull request #3609 from Abextm/config-safety

runelite-client: Don't fail on invalid config values
This commit is contained in:
Adam
2018-06-08 14:09:01 -04:00
committed by GitHub
3 changed files with 24 additions and 13 deletions

View File

@@ -85,8 +85,8 @@ public interface Actor extends Renderable
/** /**
* Gets the server-side location of the actor. * Gets the server-side location of the actor.
* <p> * <p>
* This value is typically ahead of where the client renders and may * This value is typically ahead of where the client renders and is not
* be affected by things such as animations. * affected by things such as animations.
* *
* @return the server location * @return the server location
*/ */

View File

@@ -78,16 +78,20 @@ class ConfigInvocationHandler implements InvocationHandler
// Convert value to return type // Convert value to return type
Class<?> returnType = method.getReturnType(); Class<?> returnType = method.getReturnType();
Object objectValue = ConfigManager.stringToObject(value, returnType);
// objectValue automatically gets unboxed try
// if (!objectValue.getClass().equals(returnType)) {
// { return ConfigManager.stringToObject(value, returnType);
// log.warn("Unable to convert return type for configuration item {}.{}: {}", group.keyName(), item.keyName(), returnType); }
// return null; catch (Exception e)
// } {
log.warn("Unable to unmarshal {}.{} ", group.keyName(), item.keyName(), e);
return objectValue; if (method.isDefault())
{
return callDefaultMethod(proxy, method, args);
}
return null;
}
} }
else else
{ {

View File

@@ -254,7 +254,14 @@ public class ConfigManager
String value = getConfiguration(groupName, key); String value = getConfiguration(groupName, key);
if (!Strings.isNullOrEmpty(value)) if (!Strings.isNullOrEmpty(value))
{ {
return (T) stringToObject(value, clazz); try
{
return (T) stringToObject(value, clazz);
}
catch (Exception e)
{
log.warn("Unable to unmarshal {}.{} ", groupName, key, e);
}
} }
return null; return null;
} }