Conversation
|
I definitely want to review this, hopefully this weekend. Stoked this is getting fixed! |
tgregg
left a comment
There was a problem hiding this comment.
- A few fixes requested in the tests.
- Suggestion to factor the style-related changes (import order, variable renames) into a separate PR to make this one smaller and easier to review.
- Other than that, the related fixes look good.
|
|
||
| package software.amazon.ion; | ||
|
|
||
| import software.amazon.ion.system.IonTextWriterBuilder; |
There was a problem hiding this comment.
It's probably best to configure your IDE so that it doesn't change the import order in this repo. It's bloating the size of the diff and has the potential to be reversed in a subsequent PR.
There was a problem hiding this comment.
I separated the code style changes and fiddled a bit with my IDE settings to avoid this in the future.
Do we have a style guide I can use as reference?
There was a problem hiding this comment.
For posterity: the Eclipse preferences stored in .settings. We can store preferences for IntelliJ too if needed.
| break; | ||
| case 'f': | ||
| if (valuelen == 5 // 'f' | ||
| if (valueLength == 5 // 'f' |
There was a problem hiding this comment.
Before the variable was renamed, the 'f' was in the same column as the 'alse' that follow. Please either fix that or leave the rename for a separate style-related PR.
There was a problem hiding this comment.
Separated the code style changes
| if (text == null || text.length() == 0) | ||
| if (text == null) | ||
| { | ||
| throw new EmptySymbolException(); |
There was a problem hiding this comment.
This should be NPE or IllegalArgumentException. Then we can eliminate EmptySymbolException altogether.
There was a problem hiding this comment.
I agree this would be better as NPE or IAE. However I was avoiding removing EmptySymbolException whenever possible as it breaks binary compatibility for some interfaces, since EmptySymbolException is a checked exception.
I'm pro removing it as a whole if we consider are OK with this kind of compatibility break
There was a problem hiding this comment.
What did you determine the impact to be? Will the new code compile for users who explicitly check for EmptySymbolException?
| fail("expected exception"); | ||
| } | ||
| catch (EmptySymbolException e) { } | ||
| iw.writeSymbol("a"); |
There was a problem hiding this comment.
This isn't writing an empty symbol, as the name suggests.
| throws Exception | ||
| { | ||
| iw = makeWriter(); | ||
| iw.writeSymbol(""); |
There was a problem hiding this comment.
This isn't setting a field name, it's writing a symbol value.
| IonReaderBinarySpan pos = position; | ||
|
|
||
| if (pos == null) | ||
| if (position == null) |
There was a problem hiding this comment.
I'd suggest leaving style fixes for an independent PR.
| private final String ann = "ann"; | ||
| private final String ben = "ben"; | ||
| private static final String ANN = "ANN"; | ||
| private static final String BEN = "BEN"; |
There was a problem hiding this comment.
Not related; suggest separate PR.
| int sid = value.symbolValue().getSid(); | ||
|
|
||
| try { | ||
| value.setValue(""); |
There was a problem hiding this comment.
Is there a positive test for this now?
| @Test | ||
| public void testSymbolWithEscapedNewline() | ||
| { | ||
| badValue("'\\\n'"); |
There was a problem hiding this comment.
This used to fail because \\\n is an escaped newline, which expands to nothing within quoted text, leaving this as an empty symbol value. We should be testing that that case is now valid (and is treated as an empty symbol). This might actually be a good addition to ion-tests if it's not already there.
"'\\n'" is also an interesting test; it's just a different test.
There was a problem hiding this comment.
changed it by mistake, added it back again as a valid case. Will take a look if this is included in ion-tests and add it in a separate PR if necessary
0687f34 to
e5fa879
Compare
I was mistaken this is a unchecked exception so removal is fine. Kept the class as @deprecated to avoid breaking clients
|
It works fine because EmptySymbolException is actually a RuntimeException.
I thought it was a checked Exception because it was present in some method
signatures, but that's not really the case.
For checked exceptions trying to catch something that's not thrown is a
compilation error
Example: https://gist.github.com/raganhan/e89c10169e62b4546c812134f3843d80
…On Tue, Jul 25, 2017 at 5:45 PM Tyler Gregg ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/software/amazon/ion/impl/PrivateUtils.java
<#108 (comment)>:
> @@ -228,10 +162,11 @@ public static SymbolToken newSymbolToken(SymbolTable symtab,
String text)
{
// TODO amazon-ion/ion-java#21 symtab should not be null
- if (text == null || text.length() == 0)
+ if (text == null)
{
throw new EmptySymbolException();
What did you determine the impact to be? Will the new code compile for
users who explicitly check for EmptySymbolException?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#108 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAA_NfKAl397Ac80OAUUcYmEyyDAQ_teks5sRowWgaJpZM4Of437>
.
|
Support for empty symbols, e.g. '' Empty symbols are valid according to the spec so they need to be allowed. Removed usage of EmptySymbolException as it was only used in two cases: * Empty symbols which are now supported * Java null symbols which were converted to NPEs. EmptySymbolException was kept as deprecated to avoid breaking any client that depends on it issue: #42
Issue: #42