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

OkaeriConfig.save method will clear file of content if errors to simplify any object #46

Open
Paradis4432 opened this issue Apr 18, 2024 · 1 comment

Comments

@Paradis4432
Copy link

Paradis4432 commented Apr 18, 2024

using
implementation 'eu.okaeri:okaeri-configs-yaml-bukkit:5.0.0-beta.5'
implementation 'eu.okaeri:okaeri-configs-serdes-bukkit:5.0.0-beta.5'
bukkit
severity: medium

Describe the bug
i have
https://paste.md-5.net/ihowenijat.java
as you can see theres a few values and a NPCManager, ConifgNPC, those have no ObjectSerializer registered

im using
https://paste.md-5.net/ecawikikat.cs
for testing of file loading

the method it.load is not the issue, it.save is what clears the file

the method
eu.okaeri.configs.configurer.Configurer;simplify()
will
throw new OkaeriException("cannot simplify type " + serializerType + " (" + genericType + "): '" + value + "' [" + value.getClass() + "]");
if no serializer is found for the object, but this will brake the for loop
https://paste.md-5.net/quyunoxucu.coffeescript
found in the save method

im not sure why in the
return this.save(new PrintStream(new FileOutputStream(file, false), true, StandardCharsets.UTF_8.name()));
the autoFlush is not flushing the first few values

To Reproduce
create class with no objectSerializer and let it run
call load then save, or it.load(true)

Expected behavior
avoid value or add all but that one
whatever happens, not clearing the entire config file would be great otherwise theres a need for constant backups

Library version
implementation 'eu.okaeri:okaeri-configs-yaml-bukkit:5.0.0-beta.5'
implementation 'eu.okaeri:okaeri-configs-serdes-bukkit:5.0.0-beta.5'
i only use bukkit

Config classes and setup routine
already added

fix:
as seen in the video if instead of throwing we return null the value is ignored, the error is printed to console and the file doesnt get reset
https://vimeo.com/936353158?share=copy

other:
here are a few notes iv made while debugging this
https://paste.md-5.net/zaxukusono.cs

if you need more info feel free to dm me in discord .paradis

Screenshot_27
Screenshot_26
Screenshot_28

@Paradis4432
Copy link
Author

it would be better to instead of returning null have some kind of validator in the OkaeriConfig class to warn on compile when a class added does not have an ObjectSerializer registered

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

No branches or pull requests

1 participant