public byte readByte() { try { return this.dis.readByte(); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
private void executeFutureWithTimeOut(final long maxTime, final FutureTask<?> future, final ResultCollector rc) { try { future.get(maxTime, TimeUnit.MILLISECONDS); } catch (final TimeoutException ex) { // swallow } catch (final InterruptedException e) { // swallow } catch (final ExecutionException e) { throw Unchecked.translateCheckedException(e); } }
public void close() { try { this.dos.close(); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
public void writeByte(final byte b) { try { this.dos.writeByte(b); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
public boolean readBoolean() { try { return this.dis.readBoolean(); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
public byte[] readBytes() { try { final int length = this.dis.readInt(); final byte[] data = new byte[length]; this.dis.readFully(data); return data; } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
private <T> String serialize(T t) { try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final ObjectOutputStream objectOutputStream = new ObjectOutputStream( byteArrayOutputStream); objectOutputStream.writeObject(t); return Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
public String readString() { try { return new String(readBytes(), "UTF-8"); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
@Override public void runEnd() { try { write("</mutations>\n"); this.out.close(); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
private static InputStream returnNormalBytes(final Object classPath, final String name) { try { return (InputStream) Reflection.publicMethod(classPath.getClass(), "openClassfile").invoke(classPath, name); } catch (final Exception e) { throw Unchecked.translateCheckedException(e); } }
private static InputStream returnNormalBytes(final Object classPath, final String name) { try { return (InputStream) Reflection.publicMethod(classPath.getClass(), "openClassfile").invoke(classPath, name); } catch (final Exception e) { throw Unchecked.translateCheckedException(e); } }
public void printHelp() { try { this.parser.printHelpOn(System.out); } catch (final IOException ex) { throw Unchecked.translateCheckedException(ex); } }
private void writeFooterAndClose(final Writer out) { try { write(out, "</coverage>\n"); out.close(); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
private Optional<String> createJar() { try { final File randomName = File.createTempFile(FileUtil.randomFilename(), ".jar"); final FileOutputStream fos = new FileOutputStream(randomName); createJarFromClassPathResources(fos, randomName.getAbsolutePath()); return Optional.ofNullable(randomName.getAbsolutePath()); } catch (final IOException ex) { throw Unchecked.translateCheckedException(ex); } }
@Override public void initialize() { if (this.input != null) { restoreClassPath(); restoreResults(); try { this.input.close(); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } } }
public static Runner createRunner(final Class<?> clazz) { final RunnerBuilder builder = createRunnerBuilder(); try { return builder.runnerForClass(clazz); } catch (final Throwable ex) { LOG.log(Level.SEVERE, "Error while creating runner for " + clazz, ex); throw translateCheckedException(ex); } }
@SuppressWarnings("unchecked") public <T extends Serializable> T read(final Class<T> type) { try { return (T) deserialize(readBytes()); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
public <T extends Serializable> void write(final T value) { try { writeBytes(toByteArray(value)); } catch (final IOException e) { throw Unchecked.translateCheckedException(e); } }
public static Object cloneForLoader(final Object o, final ClassLoader loader) { try { final String xml = toXml(o); final XStream foreignXstream = getXStreamForLoader(loader); return foreignXstream.fromXML(xml); } catch (final Exception ex) { throw translateCheckedException(ex); } }
@Override public Optional<byte[]> getBytes(final String classname) { final ClassPath cp = new ClassPath(new ResourceFolderClassPathroot()); try { return Optional.ofNullable(cp.getClassData(classname)); } catch (final IOException ex) { throw Unchecked.translateCheckedException(ex); } }