Abacn commented on PR #28274:
URL: https://github.com/apache/beam/pull/28274#issuecomment-1710598018

   I mean we can just change the current PR to
   ```
   .setDatumReaderFactory(
               (SerializableFunction<TableSchema, 
AvroSource.DatumReaderFactory<T>>)
                   input -> {throw new IllegalStateException("test exception");}
   ``` 
   or throw the Exception by chance, e.g.
   ```
   private static Random = new Random();
   
   ...
   .setDatumReaderFactory(
               (SerializableFunction<TableSchema, 
AvroSource.DatumReaderFactory<T>>)
                   input -> {
                     TableSchema safeInput = checkStateNotNull(input);
                     if (random.nextDouble() < _some_probability) throw new 
IllegalStateException("test exception");
                     try {
                       String jsonTableSchema = 
BigQueryIO.JSON_FACTORY.toString(safeInput);
                       return (AvroSource.DatumReaderFactory<T>)
                           (writer, reader) ->
                               new GenericDatumTransformer<>(parseFn, 
jsonTableSchema, writer);
                     } catch (IOException e) {
                       throw new IllegalStateException(
                           String.format(
                               "error converting TableSchema to JSON: %s, 
error: %s", safeInput, e));
                     }
                   })
   ```
   
   and see how the tests behaves. In general for changes that add exception to 
throw we can always tests like this


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to