Conversation
alarribeau
left a comment
There was a problem hiding this comment.
Reviewed 2 of 2 files at r1.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @clementdenis and @RaHery)
| * @throws IllegalArgumentException if {@code fieldName} is one of the reserved field | ||
| * names {@link #EXTRA_FIELDS_RESERVED_NAMES}. | ||
| */ | ||
| protected ServiceException putExtraFieldUnsafe(String fieldName, Object value) { |
There was a problem hiding this comment.
Is there any particular reason to set this method as protected while the other flavors of putExtraField are public ? This one fulfills exactly the same need as the other.
Same way, suffixing its name by unsafe is really puzzling since it has exactly the same purpose of the others. Plus, this suffix is not really invitation to use it). I would set its signature as the following :
| protected ServiceException putExtraFieldUnsafe(String fieldName, Object value) { | |
| public ServiceException putExtraField(String fieldName, Object value) { |
llbrt
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @clementdenis and @RaHery)
endpoints-framework/src/main/java/com/google/api/server/spi/ServiceException.java, line 167 at r1 (raw file):
Previously, RaHery (Hermann RANGAMANA) wrote…
Is there any particular reason to set this method as
protectedwhile the other flavors ofputExtraFieldare public ? This one fulfills exactly the same need as the other.
Same way, suffixing its name byunsafeis really puzzling since it has exactly the same purpose of the others. Plus, this suffix is not really invitation to use it). I would set its signature as the following :public ServiceException putExtraField(String fieldName, Object value) {
Yes, that's the point:
- it's not as safe as the others because the value may not be immutable
- the dev that want to use it must make more efforts 😈
Another point: the method signature may be ambiguous if we keep the same name with parameter 'Object value'.
alarribeau
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @clementdenis, @llbrt, and @RaHery)
endpoints-framework/src/main/java/com/google/api/server/spi/ServiceException.java, line 160 at r1 (raw file):
* with the same name was previously set, the old value is replaced by the specified * value.<br> * This unsafe version accepts any POJO as is: nor defensive copy nor conversion are made.
We should also mention the risk of providing a non-serializable object.
RaHery
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @clementdenis and @llbrt)
12351a9 to
3502ae6
Compare
llbrt
left a comment
There was a problem hiding this comment.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @alarribeau and @clementdenis)
endpoints-framework/src/main/java/com/google/api/server/spi/ServiceException.java, line 160 at r1 (raw file):
Previously, alarribeau wrote…
We should also mention the risk of providing a non-serializable object.
Javadoc updated.
alarribeau
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @clementdenis)
- adds a method in ServiceException to put an extra field value that may be unsafe (array, List, Map, ...) - adds a unit test
3502ae6 to
045ed34
Compare
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
============================================
+ Coverage 80.96% 80.96% +<.01%
- Complexity 1721 1722 +1
============================================
Files 159 159
Lines 6394 6395 +1
Branches 830 830
============================================
+ Hits 5177 5178 +1
Misses 907 907
Partials 310 310
Continue to review full report at Codecov.
|
value that may be unsafe (array, List, Map, ...)
This change is