Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonWriter#jsonValue(String) throws AssertionError #1268

Closed
HaedHutner opened this issue Mar 19, 2018 · 2 comments
Closed

JsonWriter#jsonValue(String) throws AssertionError #1268

HaedHutner opened this issue Mar 19, 2018 · 2 comments

Comments

@HaedHutner
Copy link

HaedHutner commented Mar 19, 2018

Relevant code:

https://github.com/Atherys-Horizons/AtherysCore/blob/master/src/main/java/com/atherys/core/gson/AbstractConfigurateAdapter.java#L39

Without getting into the details of it, logger.info(json) outputs the proper Json string. However, JsonWriter#jsonValue(String) right after it throws an AssertionError. Here is the relevant error:

`[19:35:59] [Server thread/INFO] [atheryscore]: Write: {"ContentVersion":1,"ItemType":"minecraft:anvil","Count":1,"UnsafeDamage":0,"UnsafeData":{"display":{"Name":"The Magical Anvil"}}}

[19:35:59] [Server thread/ERROR] [Sponge]: Could not pass FMLServerStartedEvent to Plugin{id=atherysquests, name=A'therys Quests, version=1.0.0b, description=A quest plugin written for the A'therys Horizons server., source=D:\Sponge1122\Server\mods\AtherysQuests-all.jar}
java.lang.AssertionError: null
at com.google.gson.internal.bind.JsonTreeWriter$1.write(JsonTreeWriter.java:36) ~[JsonTreeWriter$1.class:?]
at java.io.Writer.write(Unknown Source) ~[?:1.8.0_161]
at java.io.Writer.write(Unknown Source) ~[?:1.8.0_161]
at java.io.Writer.append(Unknown Source) ~[?:1.8.0_161]
at com.google.gson.stream.JsonWriter.jsonValue(JsonWriter.java:436) ~[JsonWriter.class:?]
at com.atherys.core.gson.AbstractConfigurateAdapter.write(AbstractConfigurateAdapter.java:44) ~[AbstractConfigurateAdapter.class:?]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[TypeAdapterRuntimeTypeWrapper.class:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:125) ~[ReflectiveTypeAdapterFactory$1.class:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:243) ~[ReflectiveTypeAdapterFactory$Adapter.class:?]
at com.google.gson.TypeAdapter.toJsonTree(TypeAdapter.java:234) ~[TypeAdapter.class:?]
at com.atherys.core.utils.RuntimeTypeAdapterFactory$1.write(RuntimeTypeAdapterFactory.java:222) ~[RuntimeTypeAdapterFactory$1.class:?]
at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:191) ~[TypeAdapter$1.class:?]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[TypeAdapterRuntimeTypeWrapper.class:?]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) ~[CollectionTypeAdapterFactory$Adapter.class:?]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) ~[CollectionTypeAdapterFactory$Adapter.class:?]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[TypeAdapterRuntimeTypeWrapper.class:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:125) ~[ReflectiveTypeAdapterFactory$1.class:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:243) ~[ReflectiveTypeAdapterFactory$Adapter.class:?]
at com.google.gson.Gson.toJson(Gson.java:669) ~[Gson.class:?]
at com.google.gson.Gson.toJson(Gson.java:648) ~[Gson.class:?]
at com.google.gson.Gson.toJson(Gson.java:603) ~[Gson.class:?]
at com.atherys.quests.AtherysQuests.start(AtherysQuests.java:120) ~[AtherysQuests.class:?]
at com.atherys.quests.AtherysQuests.onStart(AtherysQuests.java:141) ~[AtherysQuests.class:?]
at org.spongepowered.common.event.listener.GameStartedServerEventListener_AtherysQuests_onStart5.handle(Unknown Source) ~[?:?]
at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:95) ~[RegisteredListener.class:1.12.2-2611-7.1.0-BETA-2970]
at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:335) [SpongeModEventManager.class:1.12.2-2611-7.1.0-BETA-2970]
at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:368) [SpongeModEventManager.class:1.12.2-2611-7.1.0-BETA-2970]
at org.spongepowered.common.SpongeImpl.postEvent(SpongeImpl.java:213) [SpongeImpl.class:1.12.2-2611-7.1.0-BETA-2970]
at org.spongepowered.mod.SpongeMod.onStateEvent(SpongeMod.java:240) [SpongeMod.class:1.12.2-2611-7.1.0-BETA-2970]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) [minecraft_server.1.12.2.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:217) [minecraft_server.1.12.2.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:278) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:256) [LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) [minecraft_server.1.12.2.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) [minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:217) [minecraft_server.1.12.2.jar:?]
at net.minecraftforge.fml.common.LoadController.redirect$onPost$zza000(LoadController.java:560) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:148) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.serverStarted(Loader.java:784) [Loader.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarted(FMLCommonHandler.java:301) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]`

@HaedHutner
Copy link
Author

Not a Gson-related error. Please ignore.

@Marcono1234
Copy link
Collaborator

Marcono1234 commented Aug 29, 2020

This is in part actually a valid Gson issue, see #1651. In general using jsonValue(String) should be avoided if you cannot know for sure that the JsonWriter is not actually a JsonTreeWriter at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants