Skip to content
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

[fix] 'useInsensitiveEnums' feature flag fully restores old behaviour #239

Merged
merged 1 commit into from
Feb 18, 2019

Conversation

iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox commented Feb 18, 2019

Before this PR

@jcvitanovic reported problems on an internal product where empty strings were persisted to a database, but trying to opt in to the old behaviour using this feature flag would still break.

conjure {
    java {
        useInsensitiveEnums = true
    }
}

After this PR

The feature flag brings back exactly the old pre-2.8.0 behavour, where strings are leniently deserialized.

A full revert is still being considered here: #238

@iamdanfox iamdanfox requested a review from a team as a code owner February 18, 2019 13:45
@@ -75,7 +74,6 @@ public static InsensitiveEnum valueOf(String value) {
case "ONE_HUNDRED":
return ONE_HUNDRED;
default:
ConjureEnums.validate(value);
return new InsensitiveEnum(Value.UNKNOWN, value);
Copy link
Contributor Author

@iamdanfox iamdanfox Feb 18, 2019

Choose a reason for hiding this comment

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

You can see this matches the pre 2.8.0 behaviour, where no validation is performed in the UNKNOWN case.

https://github.com/palantir/conjure-java/blob/2.7.1/conjure-java-core/src/integrationInput/java/com/palantir/product/EnumExample.java#L62-L76

@bulldozer-bot bulldozer-bot bot merged commit 8bf6a57 into develop Feb 18, 2019
@bulldozer-bot bulldozer-bot bot deleted the dfox/fully-restore-case-insensitive-enums branch February 18, 2019 13:51
@Test
public void testInsensitiveEnum_unknownToleratesEmptyStringsForHistoricalReasons() {
InsensitiveEnum value = InsensitiveEnum.valueOf("");
assertThat(value.get()).isEqualTo(InsensitiveEnum.Value.UNKNOWN);

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants