@Override
public SchemaIdVersion addSchemaVersion(final String schemaBranchName, final String schemaName, final SchemaVersion schemaVersion)
throws InvalidSchemaException, IncompatibleSchemaException, SchemaNotFoundException, SchemaBranchNotFoundException {
try {
return schemaTextCache.get(buildSchemaTextEntry(schemaVersion, schemaName),
() -> doAddSchemaVersion(schemaBranchName, schemaName, schemaVersion));
} catch (ExecutionException e) {
Throwable cause = e.getCause();
LOG.error("Encountered error while adding new version [{}] of schema [{}] and error [{}]", schemaVersion, schemaName, e);
if (cause != null) {
if (cause instanceof InvalidSchemaException)
throw (InvalidSchemaException) cause;
else if (cause instanceof IncompatibleSchemaException) {
throw (IncompatibleSchemaException) cause;
} else if (cause instanceof SchemaNotFoundException) {
throw (SchemaNotFoundException) cause;
} else {
throw new RuntimeException(cause.getMessage(), cause);
}
} else {
throw new RuntimeException(e.getMessage(), e);
}
}
}