Skip to content

Make EncoderException a RuntimeException #1180

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

Merged
merged 3 commits into from
Jan 30, 2020
Merged

Conversation

rlazo
Copy link
Collaborator

@rlazo rlazo commented Jan 30, 2020

An error encoding a message is more likely to be unrecoverable than the other way around. Making EncoderException unchecked would reflect this case, instead of forcing teams to use the catch-log-rethrow pattern.

For reference, GSON does something similar

https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/JsonParseException.html

This exception is a RuntimeException because it is exposed to the client. Using a RuntimeException avoids bad coding practices on the client side where they catch the exception and do nothing. It is often the case that you want to blow up if there is a parsing error (i.e. often clients do not know how to recover from a JsonParseException.

@rlazo rlazo requested a review from vkryachko January 30, 2020 15:45
@googlebot googlebot added the cla: yes Override cla label Jan 30, 2020
@codecov
Copy link

codecov bot commented Jan 30, 2020

Codecov Report

Merging #1180 into master will increase coverage by 5.1%.
The diff coverage is 100%.

Flag Coverage Δ Complexity Δ
#Encoders_FirebaseEncodersJson 95.93% <100%> (+0.28%) 68 <8> (+6) ⬆️
#Encoders_FirebaseEncodersProcessor ? ?
#Encoders_FirebaseEncodersReflective 73.97% <ø> (?) 20 <ø> (?)
#FirebaseDatatransport 100% <ø> (ø) 3 <ø> (ø) ⬇️
#FirebaseInappmessaging 51.15% <ø> (ø) 520 <ø> (ø) ⬇️
#FirebaseInappmessagingDisplay 34.52% <ø> (ø) 129 <ø> (ø) ⬇️
#FirebaseInappmessagingDisplay_Ktx 100% <ø> (ø) 0 <ø> (ø) ⬇️
#FirebaseInappmessaging_Ktx 100% <ø> (ø) 0 <ø> (ø) ⬇️
#Transport_TransportBackendCct 91.38% <ø> (?) 96 <ø> (?)
Impacted Files Coverage Δ Complexity Δ
...e/encoders/reflective/ReflectiveObjectEncoder.java 94.44% <ø> (ø) 8 <0> (?)
...rs/reflective/ReflectiveObjectEncoderProvider.java 67.27% <ø> (ø) 12 <0> (?)
...e/encoders/json/JsonValueObjectEncoderContext.java 96.66% <100%> (+0.23%) 56 <6> (+4) ⬆️
...firebase/encoders/json/JsonDataEncoderBuilder.java 93.02% <100%> (+0.52%) 10 <2> (+2) ⬆️
...atransport/cct/internal/NetworkConnectionInfo.java 100% <0%> (ø) 2% <0%> (?)
...ansport/cct/internal/AndroidClientInfoEncoder.java 94.44% <0%> (ø) 9% <0%> (?)
...android/datatransport/cct/internal/ClientInfo.java 100% <0%> (ø) 2% <0%> (?)
...ansport/cct/internal/BatchedLogRequestEncoder.java 100% <0%> (ø) 2% <0%> (?)
.../datatransport/cct/internal/ClientInfoEncoder.java 66.66% <0%> (ø) 2% <0%> (?)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 645e879...2e78c7f. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 30, 2020

Codecov Report

Merging #1180 into master will increase coverage by 41.06%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##             master    #1180       +/-   ##
=============================================
+ Coverage     54.59%   95.65%   +41.06%     
+ Complexity     6360       62     -6298     
=============================================
  Files           697        3      -694     
  Lines         33366      184    -33182     
  Branches       4525       28     -4497     
=============================================
- Hits          18215      176    -18039     
+ Misses        13692        5    -13687     
+ Partials       1459        3     -1456     
Flag Coverage Δ Complexity Δ
#Encoders_FirebaseEncodersJson 95.65% <ø> (-4.35%) 62.00 <ø> (+62.00)
#Encoders_FirebaseEncodersProcessor 100.00% <ø> (ø) 0.00 <ø> (ø) ⬆️
#Encoders_FirebaseEncodersReflective ? ?
#FirebaseAbt ? ?
#FirebaseCommon ? ?
#FirebaseCommon_DataCollectionTests ? ?
#FirebaseCommon_Ktx ? ?
#FirebaseComponents ? ?
#FirebaseConfig ? ?
#FirebaseConfig_Ktx ? ?
#FirebaseCrashlytics ? ?
#FirebaseDatabase ? ?
#FirebaseDatabaseCollection ? ?
#FirebaseDatabase_Ktx ? ?
#FirebaseDatatransport ? ?
#FirebaseDynamicLinks ? ?
#FirebaseDynamicLinks_Ktx ? ?
#FirebaseFirestore ? ?
#FirebaseFirestore_Ktx ? ?
#FirebaseFunctions ? ?
#FirebaseFunctions_Ktx ? ?
#FirebaseInappmessaging ? ?
#FirebaseInappmessagingDisplay ? ?
#FirebaseInappmessagingDisplay_Ktx ? ?
#FirebaseInappmessaging_Ktx ? ?
#FirebaseInstallations ? ?
#FirebaseSegmentation ? ?
#FirebaseStorage ? ?
#FirebaseStorage_Ktx ? ?
#Tools_Errorprone ? ?
#Tools_Lint ? ?
#Transport_TransportBackendCct ? ?
#Transport_TransportRuntime ? ?
Impacted Files Coverage Δ Complexity Δ
...om/google/firebase/encoders/EncodingException.java 100.00% <0.00%> (ø) 2.00% <0.00%> (ø%) ⬆️
...loud/datastore/core/number/IndexNumberDecoder.java
.../google/firebase/firestore/local/ReferenceSet.java
...e/firebase/firestore/model/value/IntegerValue.java
...firebase/firestore/local/IndexFreeQueryEngine.java
...om/google/firebase/firestore/core/OnlineState.java
...irebase/components/AbstractComponentContainer.java
...google/firebase/firestore/core/KeyFieldFilter.java
...oogle/firebase/firestore/util/BackgroundQueue.java
...le/firebase/inappmessaging/internal/ApiClient.java
... and 679 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08af4ed...645e879. Read the comment docs.

Copy link
Member

@vkryachko vkryachko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind explaining the motivation for this change in the PR description and the final commit message?
LGTM otherwise

@rlazo rlazo merged commit b5831f4 into master Jan 30, 2020
@rlazo rlazo deleted the rl.encoders-exception-runtime branch January 30, 2020 22:27
@firebase firebase locked and limited conversation to collaborators Mar 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Override cla size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants