@Test public void getCodecNoName() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Compression codec some.bad.codec was not found."); Configuration conf = new Configuration(); String name = "some.bad.codec"; factory.getCodec(name, conf); }
public CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec) { if (name == null) return defaultCodec; try { return CompressionCodecName.fromConf(name); } catch (IllegalArgumentException ie) { try { return CompressionCodecName.fromCompressionCodec(Class.forName(name)); } catch (ClassNotFoundException ce) { throw new IllegalArgumentException(String.format("Invalid codec: %s ", name)); } } }
CodecFactory { public CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec) { if (name == null) return defaultCodec; try { return CompressionCodecName.fromConf(name); } catch (IllegalArgumentException ie) { try { return CompressionCodecName.fromCompressionCodec(Class.forName(name)); } catch (ClassNotFoundException ce) { throw new IllegalArgumentException(String.format("Invalid codec: %s ", name)); } } } }
CodecFactory { public CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec) { if (name == null) return defaultCodec; try { return CompressionCodecName.fromConf(name); } catch (IllegalArgumentException ie) { try { return CompressionCodecName.fromCompressionCodec(Class.forName(name)); } catch (ClassNotFoundException ce) { throw new IllegalArgumentException(String.format("Invalid codec: %s ", name)); } } }  }
CodecFactory { public CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec) { if (name == null) return defaultCodec; try { return CompressionCodecName.fromConf(name); } catch (IllegalArgumentException ie) { try { return CompressionCodecName.fromCompressionCodec(Class.forName(name)); } catch (ClassNotFoundException ce) { throw new IllegalArgumentException(String.format("Invalid codec: %s ", name)); } } }  CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec); CompressionCodec getCodec(String name, Configuration conf); Class<? extends CompressionCodec> getCodecClass(String name, Configuration conf); boolean isCodecThreadSafe(String compCodec, String dataSource, Configuration configuration); static CodecFactory getInstance(); }
CodecFactory { public CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec) { if (name == null) return defaultCodec; try { return CompressionCodecName.fromConf(name); } catch (IllegalArgumentException ie) { try { return CompressionCodecName.fromCompressionCodec(Class.forName(name)); } catch (ClassNotFoundException ce) { throw new IllegalArgumentException(String.format("Invalid codec: %s ", name)); } } }  CompressionCodecName getCodec(String name, CompressionCodecName defaultCodec); CompressionCodec getCodec(String name, Configuration conf); Class<? extends CompressionCodec> getCodecClass(String name, Configuration conf); boolean isCodecThreadSafe(String compCodec, String dataSource, Configuration configuration); static CodecFactory getInstance();  }