use of com.google.protobuf.Descriptors.DescriptorValidationException in project tesla by linking12.
the class ServiceResolver method fromFileDescriptorSet.
public static ServiceResolver fromFileDescriptorSet(FileDescriptorSet descriptorSet) {
ImmutableMap<String, FileDescriptorProto> descriptorProtoIndex = computeDescriptorProtoIndex(descriptorSet);
Map<String, FileDescriptor> descriptorCache = new HashMap<>();
ImmutableList.Builder<FileDescriptor> result = ImmutableList.builder();
for (FileDescriptorProto descriptorProto : descriptorSet.getFileList()) {
try {
result.add(descriptorFromProto(descriptorProto, descriptorProtoIndex, descriptorCache));
} catch (DescriptorValidationException e) {
logger.warn("Skipped descriptor " + descriptorProto.getName() + " due to error", e);
continue;
}
}
return new ServiceResolver(result.build());
}
use of com.google.protobuf.Descriptors.DescriptorValidationException in project BIMserver by opensourceBIM.
the class ProtocolBuffersMetaData method load.
public void load(InputStream inputStream) {
try {
FileDescriptorSet descriptorSet = FileDescriptorSet.parseFrom(inputStream);
List<FileDescriptorProto> fileList = descriptorSet.getFileList();
FileDescriptorProto fileDescriptorProto = fileList.get(0);
FileDescriptor[] dependencyDescriptors = getDependencyDescriptors(fileDescriptorProto);
FileDescriptor fileDescriptor = FileDescriptor.buildFrom(fileDescriptorProto, dependencyDescriptors);
loaded.put(fileDescriptor.getName(), fileDescriptor);
fileDescriptor.getMessageTypes().forEach(descriptor -> this.messageDescriptors.put(descriptor.getName(), new MessageDescriptorContainer(descriptor)));
fileDescriptor.getServices().forEach(serviceDescriptor -> this.serviceDescriptors.put(serviceDescriptor.getName(), new ServiceDescriptorContainer(serviceDescriptor)));
} catch (IOException e) {
LOGGER.error("", e);
} catch (DescriptorValidationException e) {
LOGGER.error("", e);
} finally {
try {
inputStream.close();
} catch (IOException e) {
LOGGER.error("", e);
}
}
}
Aggregations