Mojira Archive
MC-87587

Server kicks client when executing: /title @a title [] or tellraw @a []

The bug

When this command is executed:

/title @a title []

it kicks me from the world/server and displays this error:

Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1

In 1.8 the command was working.

Code analysis

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

This bug would be fixed by using the "fix" provided for MC-55373.

The reason why this happens is because the method net.minecraft.util.text.ITextComponent.Serializer.deserialize(JsonElement, Type, JsonDeserializationContext) returns null when parsing an empty array because it only sets the chat component which should be returned to a value if the array contains items.

public ITextComponent deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    if (p_deserialize_1_.isJsonPrimitive())
    {
        return new TextComponentString(p_deserialize_1_.getAsString());
    }
    else if (!p_deserialize_1_.isJsonObject())
    {
        if (p_deserialize_1_.isJsonArray())
        {
            JsonArray jsonarray1 = p_deserialize_1_.getAsJsonArray();
            ITextComponent itextcomponent1 = null;

            // No items are in the array meaning "itextcomponent1" stays "null"
            for (JsonElement jsonelement : jsonarray1)
            {
                ITextComponent itextcomponent2 = this.deserialize(jsonelement, jsonelement.getClass(), p_deserialize_3_);

                if (itextcomponent1 == null)
                {
                    itextcomponent1 = itextcomponent2;
                }
                else
                {
                    itextcomponent1.appendSibling(itextcomponent2);
                }
            }

            return itextcomponent1;
        }
        else
        {
            throw new JsonParseException("Don\'t know how to turn " + p_deserialize_1_.toString() + " into a Component");
        }
    }
    //...
}