Search in sources :

Example 1 with BadCommand

use of com.cloud.agent.api.BadCommand in project cloudstack by apache.

the class Request method getCommands.

public Command[] getCommands() {
    if (_cmds == null) {
        try {
            StringReader reader = new StringReader(_content);
            JsonReader jsonReader = new JsonReader(reader);
            jsonReader.setLenient(true);
            _cmds = s_gson.fromJson(jsonReader, (Type) Command[].class);
        } catch (JsonParseException e) {
            _cmds = new Command[] { new BadCommand() };
        } catch (RuntimeException e) {
            s_logger.error("Caught problem with " + _content, e);
            throw e;
        }
    }
    return _cmds;
}
Also used : Type(java.lang.reflect.Type) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) BadCommand(com.cloud.agent.api.BadCommand) Command(com.cloud.agent.api.Command) BadCommand(com.cloud.agent.api.BadCommand) StringReader(java.io.StringReader) JsonReader(com.google.gson.stream.JsonReader) JsonParseException(com.google.gson.JsonParseException)

Aggregations

BadCommand (com.cloud.agent.api.BadCommand)1 Command (com.cloud.agent.api.Command)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 JsonParseException (com.google.gson.JsonParseException)1 JsonReader (com.google.gson.stream.JsonReader)1 StringReader (java.io.StringReader)1 Type (java.lang.reflect.Type)1