Skip to content

Commit

Permalink
java: raise an exception on conversion of unknown polymorphic types i…
Browse files Browse the repository at this point in the history
…n Java SDK

Rather than silently succeeding (returning None), raise an exception.

This brings the Java SDK in line with the behaviour of the Go SDK.

Includes some rudimentary test coverage to demonstrate this works for one of those types.

JAVADEPS was updated solely for the change of io.grpc from a runtime to an
implementation dependency for the tests, which was required to construct a GRPC
exception to exercise the exception conversion code.

GitOrigin-RevId: 6743b0e76616eaee0e9fe1f8583bd4f123092a5b
  • Loading branch information
kjamieson-sdm authored and SupportSDM committed Dec 21, 2022
1 parent c52dccf commit ffdd10a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions com/strongdm/api/plumbing/Plumbing.java
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ public static com.strongdm.api.Account convertAccountToPorcelain(Account plumbin
if (plumbing.hasUser()) {
return convertUserToPorcelain(plumbing.getUser());
}
return null;
throw new UnknownException("unknown polymorphic type, please upgrade your SDK");
}

public static Account convertAccountToPlumbing(com.strongdm.api.Account porcelain) {
Expand Down Expand Up @@ -5707,7 +5707,7 @@ public static com.strongdm.api.Node convertNodeToPorcelain(Node plumbing) {
if (plumbing.hasRelay()) {
return convertRelayToPorcelain(plumbing.getRelay());
}
return null;
throw new UnknownException("unknown polymorphic type, please upgrade your SDK");
}

public static Node convertNodeToPlumbing(com.strongdm.api.Node porcelain) {
Expand Down Expand Up @@ -7118,7 +7118,7 @@ public static com.strongdm.api.Resource convertResourceToPorcelain(Resource plum
if (plumbing.hasTeradata()) {
return convertTeradataToPorcelain(plumbing.getTeradata());
}
return null;
throw new UnknownException("unknown polymorphic type, please upgrade your SDK");
}

public static Resource convertResourceToPlumbing(com.strongdm.api.Resource porcelain) {
Expand Down Expand Up @@ -8274,7 +8274,7 @@ public static com.strongdm.api.SecretStore convertSecretStoreToPorcelain(SecretS
if (plumbing.hasVaultToken()) {
return convertVaultTokenStoreToPorcelain(plumbing.getVaultToken());
}
return null;
throw new UnknownException("unknown polymorphic type, please upgrade your SDK");
}

public static SecretStore convertSecretStoreToPlumbing(com.strongdm.api.SecretStore porcelain) {
Expand Down

0 comments on commit ffdd10a

Please sign in to comment.