@Test public void read_onParsingException_absorbsError() throws IOException { when(parser.parseFrom(fileInputStream)).thenThrow(new InvalidProtocolBufferException("")); TestObserver<FetchEligibleCampaignsResponse> subscriber = protoStorageClient.read(parser).test(); subscriber.assertNoErrors(); subscriber.assertNoValues(); }
public <T extends AbstractMessageLite> Maybe<T> read(Parser<T> parser) { return Maybe.fromCallable( () -> { synchronized (this) { try (FileInputStream inputStream = application.openFileInput(fileName)) { return parser.parseFrom(inputStream); } catch (InvalidProtocolBufferException | FileNotFoundException e) { Logging.logi("Recoverable exception while reading cache: " + e.getMessage()); return null; } } }); }
ProtoStorageClient { public <T extends AbstractMessageLite> Maybe<T> read(Parser<T> parser) { return Maybe.fromCallable( () -> { synchronized (this) { try (FileInputStream inputStream = application.openFileInput(fileName)) { return parser.parseFrom(inputStream); } catch (InvalidProtocolBufferException | FileNotFoundException e) { Logging.logi("Recoverable exception while reading cache: " + e.getMessage()); return null; } } }); } }
ProtoStorageClient { public <T extends AbstractMessageLite> Maybe<T> read(Parser<T> parser) { return Maybe.fromCallable( () -> { synchronized (this) { try (FileInputStream inputStream = application.openFileInput(fileName)) { return parser.parseFrom(inputStream); } catch (InvalidProtocolBufferException | FileNotFoundException e) { Logging.logi("Recoverable exception while reading cache: " + e.getMessage()); return null; } } }); } ProtoStorageClient(Application application, String fileName); }
ProtoStorageClient { public <T extends AbstractMessageLite> Maybe<T> read(Parser<T> parser) { return Maybe.fromCallable( () -> { synchronized (this) { try (FileInputStream inputStream = application.openFileInput(fileName)) { return parser.parseFrom(inputStream); } catch (InvalidProtocolBufferException | FileNotFoundException e) { Logging.logi("Recoverable exception while reading cache: " + e.getMessage()); return null; } } }); } ProtoStorageClient(Application application, String fileName); Completable write(AbstractMessageLite messageLite); Maybe<T> read(Parser<T> parser); }
ProtoStorageClient { public <T extends AbstractMessageLite> Maybe<T> read(Parser<T> parser) { return Maybe.fromCallable( () -> { synchronized (this) { try (FileInputStream inputStream = application.openFileInput(fileName)) { return parser.parseFrom(inputStream); } catch (InvalidProtocolBufferException | FileNotFoundException e) { Logging.logi("Recoverable exception while reading cache: " + e.getMessage()); return null; } } }); } ProtoStorageClient(Application application, String fileName); Completable write(AbstractMessageLite messageLite); Maybe<T> read(Parser<T> parser);  }