use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusChecker method fetchServerInfos.
private ServerInfos fetchServerInfos() {
try (WsResponse response = wsClient.rawGet("api/system/status")) {
if (!response.isSuccessful()) {
if (response.code() == HttpURLConnection.HTTP_NOT_FOUND) {
return tryFromDeprecatedApi(response);
} else {
throw SonarLintWsClient.handleError(response);
}
} else {
String responseStr = response.content();
try {
ServerInfos.Builder builder = ServerInfos.newBuilder();
JsonFormat.parser().merge(responseStr, builder);
return builder.build();
} catch (InvalidProtocolBufferException e) {
throw new IllegalStateException("Unable to parse server infos from: " + StringUtils.abbreviate(responseStr, 100), e);
}
}
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project CorfuDB by CorfuDB.
the class StreamLogFiles method readAddressSpace.
/**
* Reads an address space from a log file into a SegmentHandle
*
* @param sh
*/
private void readAddressSpace(SegmentHandle sh) throws IOException {
long logFileSize;
try (MultiReadWriteLock.AutoCloseableLock ignored = segmentLocks.acquireReadLock(sh.getSegment())) {
logFileSize = sh.logChannel.size();
}
FileChannel fc = getChannel(sh.fileName, true);
if (fc == null) {
log.trace("Can't read address space, {} doesn't exist", sh.fileName);
return;
}
// Skip the header
ByteBuffer headerMetadataBuf = ByteBuffer.allocate(METADATA_SIZE);
fc.read(headerMetadataBuf);
headerMetadataBuf.flip();
Metadata headerMetadata = Metadata.parseFrom(headerMetadataBuf.array());
fc.position(fc.position() + headerMetadata.getLength());
long channelOffset = fc.position();
ByteBuffer o = ByteBuffer.allocate((int) logFileSize - (int) fc.position());
fc.read(o);
fc.close();
o.flip();
while (o.hasRemaining()) {
short magic = o.getShort();
channelOffset += Short.BYTES;
if (magic != RECORD_DELIMITER) {
log.error("Expected a delimiter but found something else while trying to read file {}", sh.fileName);
throw new DataCorruptionException();
}
byte[] metadataBuf = new byte[METADATA_SIZE];
o.get(metadataBuf);
channelOffset += METADATA_SIZE;
try {
Metadata metadata = Metadata.parseFrom(metadataBuf);
byte[] logEntryBuf = new byte[metadata.getLength()];
o.get(logEntryBuf);
LogEntry entry = LogEntry.parseFrom(logEntryBuf);
if (!noVerify) {
if (metadata.getChecksum() != getChecksum(entry.toByteArray())) {
log.error("Checksum mismatch detected while trying to read file {}", sh.fileName);
throw new DataCorruptionException();
}
}
sh.knownAddresses.put(entry.getGlobalAddress(), new AddressMetaData(metadata.getChecksum(), metadata.getLength(), channelOffset));
channelOffset += metadata.getLength();
} catch (InvalidProtocolBufferException e) {
throw new DataCorruptionException();
}
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project sulky by huxi.
the class MetaDataDecoder method decode.
public MetaData decode(byte[] bytes) {
if (bytes == null) {
return null;
}
MetaDataProto.MetaData parsedData = null;
if (!compressing) {
try {
parsedData = MetaDataProto.MetaData.parseFrom(bytes);
} catch (InvalidProtocolBufferException e) {
// ignore
}
} else {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
try {
GZIPInputStream gis = new GZIPInputStream(in);
parsedData = MetaDataProto.MetaData.parseFrom(gis);
gis.close();
} catch (IOException e) {
// ignore
}
}
return convert(parsedData);
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project core-java by SpineEventEngine.
the class MetadataConverter method toError.
/**
* Returns the {@link Error} extracted from the {@link Metadata}.
*
* @param metadata the metadata to convert
* @return the error extracted from the metadata or {@code Optional.absent()}
* if there is no error.
*/
public static Optional<Error> toError(Metadata metadata) {
checkNotNull(metadata);
final byte[] bytes = metadata.get(KEY);
if (bytes == null) {
return Optional.absent();
}
try {
final Error error = Error.parseFrom(bytes);
return Optional.of(error);
} catch (InvalidProtocolBufferException e) {
throw Exceptions.illegalStateWithCauseOf(e);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project yamcs-studio by yamcs.
the class CommandingCatalogue method initialiseState.
private void initialiseState() {
log.fine("Fetching available commands");
YamcsClient restClient = YamcsPlugin.getYamcsClient();
String instance = ManagementCatalogue.getCurrentYamcsInstance();
restClient.get("/mdb/" + instance + "/commands", null).whenComplete((data, exc) -> {
try {
ListCommandInfoResponse response = ListCommandInfoResponse.parseFrom(data);
processMetaCommands(response.getCommandList());
} catch (InvalidProtocolBufferException e) {
log.log(Level.SEVERE, "Failed to decode server response", e);
}
});
}
Aggregations