-
-
Notifications
You must be signed in to change notification settings - Fork 16
Improve null-safety in Factories and cleanup #53
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
Improve null-safety in Factories and cleanup #53
Conversation
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
We should have an approach that isn't specific to Most often the exception is logged because
Here we would have the I think it's better to not make any assumptions about the content of elements in dav4jvm (maybe except if explicitly required by the standard, but even then we should parse as forgiving as possible). If at all, this should be left to the application that uses dav4jvm. So, I suggest to
So for instance the Push |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
I've deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would solve the existing problem (see #9) that this can't be parsed without information loss:
<multistatus>
… with 404: …
<prop>
<getetag/>
</prop>
</multistatus>
to consequently allow empty properties.
So in the case of GetETag
, we have to deal with the situation above, so it should be possible to generate an empty GetETag
. Who knows, maybe the receiving app needs to list the 404 properties, or maybe there's at some day something like:
<this-server-supports>
<getetag/>
</this-server-supports>
Then we also need the empty GetETag
element.
So, we should parse and return a GetETag
in this case, but without content (String value may be null).
Same applies to all elements.
@Deprecated( | ||
message = "Use readText instead. This function throws exceptions for unexpected contents.", | ||
replaceWith = ReplaceWith("readText(parser)") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should drop it completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same applies to all elements.
Do you mean all? Like, make PropertyFactory.create
return non-null? Or just Topic
, GetETag
and PushSubscribe
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example CalendarColor
requires an int color, we can always set to black or something like that but I'm not sure if we want that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd allow null
too for the same reason: It may be interesting for an application to know that an empty element was transmitted.
I have thought about returning some kind of for instance Empty<CalendarColor>
when CalendarColor
couldn't be parsed with value, but it makes thing unnecessary complex.
The HrefListProperty
properties should automatically work. The others often already allow null
values. I think we should consequently allow null
values in all properties, also to be consistent.
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Real-world example of misleading logs from accessing a WebDAV folder in DAVx5:
because the folder doesn't have a
although the property is known (but it can be parsed because it currently requires a value). |
Okay, I'll make all properties nullable then 😉 |
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some requests 😃
Also please provide a short PR summary. It can be very short like "Currently there's misleading logging, so now we do this and that: - …, - …", but at least to have an idea what it's about.
And it's often not exactly the same the issue, like in this case. The issue is just about the logging, but the PR is now about null values etc.
src/main/kotlin/at/bitfire/dav4jvm/property/caldav/SupportedCalendarData.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/at/bitfire/dav4jvm/property/carddav/SupportedAddressData.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/at/bitfire/dav4jvm/property/webdav/GetLastModified.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Should be ready. Sorry for the long PR, but there are a lot of classes that use the same methods 😅 |
f6f905b
to
d38137b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, logging should be more intuitive now and we've on the go also fixed the root cause of #9.
Code cleanup, including new utility functions and a new
XmlReader
class which simplifies the factory classes.