Comments (5)
I prefer the current implementation. We have a convention of adding optional
to every field explicitly. But generally, It makes more sense to generate all of them nullable
by default, because this convention is just a thing we made up.
Also, if field
is unset in the non-null implementation, are we seeing a NullPointerException
in runtime?
We use https://github.com/bufbuild/protovalidate
to ensure field nullability for example. I had a long conversation in pbandk issues. Ability to generate code as nullable or not nullable based on certain options. What do you think about this?
from krotodc.
Also, if field is unset in the non-null implementation, are we seeing a NullPointerException in runtime?
No, these fields are set with default instances
from krotodc.
I also agree that having an option for both is the best way to go.
from krotodc.
Also, if field is unset in the non-null implementation, are we seeing a NullPointerException in runtime?
No, these fields are set with default instances
One reason why Proto uses unset
as the default instance rather than null
is recursion
message LinkedList {
string value = 1;
LinkedList next = 2;
}
In this case, the generated code shouldn't really work, right? I assume Kotlin code looks like this:
data class LinkedList(
val value: String,
val next: LinkedList,
)
Which is basically impossible to initialize. As long as code throws an appropriate error, I like it.
from krotodc.
Sorry for late response, I am reproducing the bug here: #19
Because every message is optional
by default, I expect to see this behavior time to time.
from krotodc.
Related Issues (10)
- Windows support HOT 6
- Reserved keywords are not escaped HOT 1
- Fix flaky WellKnownTypesTest junit tests HOT 2
- [discussion] compatible with two cases HOT 2
- Enum argument can be null in Java, but exhaustive when contains no null branch HOT 3
- Future vision and stability HOT 2
- Problem when the name of a 'oneof' field matches the name of the message. HOT 1
- Generated defaultValue for TIMESTAMP is `LocalDateTime.MIN` HOT 1
- Tests not executed on `./gradlew test` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from krotodc.