Java Code Examples for java.io.UncheckedIOException

The following are top voted examples for showing how to use java.io.UncheckedIOException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jdk8u-jdk   File: StreamTest.java   View source code 7 votes vote down vote up
private void validateFileSystemLoopException(Path start, Path... causes) {
    try (Stream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
        try {
            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
            fail("Should got FileSystemLoopException, but got " + count + "elements.");
        } catch (UncheckedIOException uioe) {
            IOException ioe = uioe.getCause();
            if (ioe instanceof FileSystemLoopException) {
                FileSystemLoopException fsle = (FileSystemLoopException) ioe;
                boolean match = false;
                for (Path cause: causes) {
                    if (fsle.getFile().equals(cause.toString())) {
                        match = true;
                        break;
                    }
                }
                assertTrue(match);
            } else {
                fail("Unexpected UncheckedIOException cause " + ioe.toString());
            }
        }
    } catch(IOException ex) {
        fail("Unexpected IOException " + ex);
    }
}
 
Example 2
Project: centraldogma   File: EntryConverter.java   View source code 6 votes vote down vote up
@Override
protected com.linecorp.centraldogma.common.Entry<?> doBackward(Entry entry) {
    switch (entry.getType()) {
        case JSON:
            try {
                JsonNode value = Jackson.readTree(entry.getContent());
                return com.linecorp.centraldogma.common.Entry.ofJson(entry.getPath(), value);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        case TEXT:
            return com.linecorp.centraldogma.common.Entry.ofText(entry.getPath(), entry.getContent());
        case DIRECTORY:
            return com.linecorp.centraldogma.common.Entry.ofDirectory(entry.getPath());
        default:
            throw new IllegalArgumentException("unsupported entry type: " + entry.getType());
    }
}
 
Example 3
Project: pipeline-github   File: CommitGroovyObject.java   View source code 6 votes vote down vote up
@Whitelisted
public CommitStatusGroovyObject createStatus(final String status,
                                             final String context,
                                             final String description,
                                             final String targetUrl) {
    Objects.requireNonNull(status, "status is a required argument");

    CommitStatus commitStatus = new CommitStatus();
    commitStatus.setState(status);
    commitStatus.setContext(context);
    commitStatus.setDescription(description);
    commitStatus.setTargetUrl(targetUrl);
    try {
        return new CommitStatusGroovyObject(
                commitService.createStatus(base, commit.getSha(), commitStatus));
    } catch (final IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 4
Project: mpd-2017-i41d   File: FileRequest.java   View source code 6 votes vote down vote up
@Override
public Iterable<String> getContent(String path) {
    String[] parts = path.split("/");
    path = parts[parts.length-1]
            .replace('?', '-')
            .replace('&', '-')
            .replace('=', '-')
            .replace(',', '-')
            .substring(0,68);
    try {
        InputStream in = ClassLoader.getSystemResource(path).openStream();
        /*
         * Consumir o Inputstream e adicionar dados ao res
         */
        Iterator<String> iter = new IteratorFromReader(in);
        return () -> iter;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 5
Project: moduletools   File: JITTraceReader.java   View source code 6 votes vote down vote up
private static Map<String, Set<String>> readClassAsEntry(InputStream input) {
  HashMap<String, Set<String>> map = new HashMap<>(); 
  try {
    ClassReader reader = new ClassReader(input);
    String className = reader.getClassName().replace('/', '.');
    reader.accept(new ClassVisitor(Opcodes.ASM6) {
      @Override
      public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        String methodName = className + '.' + name;
        map.computeIfAbsent(methodName, __ -> new HashSet<>()).add(methodName + desc);
        return null;
      }
    }, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
  } catch(IOException e) {
    throw new UncheckedIOException(e);
  }
  return map;
}
 
Example 6
Project: nakadi-producer-spring-boot-starter   File: EventTransmissionService.java   View source code 6 votes vote down vote up
public NakadiEvent mapToNakadiEvent(final EventLog event) {
    final NakadiEvent nakadiEvent = new NakadiEvent();

    final NakadiMetadata metadata = new NakadiMetadata();
    metadata.setEid(convertToUUID(event.getId()));
    metadata.setOccuredAt(event.getCreated());
    metadata.setFlowId(event.getFlowId());
    nakadiEvent.setMetadata(metadata);

    HashMap<String, Object> payloadDTO;
    try {
        payloadDTO = objectMapper.readValue(event.getEventBodyData(), new TypeReference<LinkedHashMap<String, Object>>() { });
    } catch (IOException e) {
        log.error("An error occurred at JSON deserialization", e);
        throw new UncheckedIOException(e);
    }

    nakadiEvent.setData(payloadDTO);

    return nakadiEvent;
}
 
Example 7
Project: openjdk-jdk10   File: AbstractResourceBundleProvider.java   View source code 6 votes vote down vote up
/**
 * Returns a {@code ResourceBundle} for the given {@code baseName} and
 * {@code locale}.
 *
 * @implNote
 * The default implementation of this method calls the
 * {@link #toBundleName(String, Locale) toBundleName} method to get the
 * bundle name for the {@code baseName} and {@code locale} and finds the
 * resource bundle of the bundle name local in the module of this provider.
 * It will only search the formats specified when this provider was
 * constructed.
 *
 * @param baseName the base bundle name of the resource bundle, a fully
 *                 qualified class name.
 * @param locale the locale for which the resource bundle should be instantiated
 * @return {@code ResourceBundle} of the given {@code baseName} and
 *         {@code locale}, or {@code null} if no resource bundle is found
 * @throws NullPointerException if {@code baseName} or {@code locale} is
 *         {@code null}
 * @throws UncheckedIOException if any IO exception occurred during resource
 *         bundle loading
 */
@Override
public ResourceBundle getBundle(String baseName, Locale locale) {
    Module module = this.getClass().getModule();
    String bundleName = toBundleName(baseName, locale);
    ResourceBundle bundle = null;

    for (String format : formats) {
        try {
            if (FORMAT_CLASS.equals(format)) {
                bundle = loadResourceBundle(module, bundleName);
            } else if (FORMAT_PROPERTIES.equals(format)) {
                bundle = loadPropertyResourceBundle(module, bundleName);
            }
            if (bundle != null) {
                break;
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
    return bundle;
}
 
Example 8
Project: openjdk-jdk10   File: Exchange.java   View source code 6 votes vote down vote up
public void cancel(IOException cause) {
    // If the impl is non null, propagate the exception right away.
    // Otherwise record it so that it can be propagated once the
    // exchange impl has been established.
    ExchangeImpl<?> impl = exchImpl;
    if (impl != null) {
        // propagate the exception to the impl
        impl.cancel(cause);
    } else {
        try {
            // no impl yet. record the exception
            failed = cause;
            // now call checkCancelled to recheck the impl.
            // if the failed state is set and the impl is not null, reset
            // the failed state and propagate the exception to the impl.
            checkCancelled(false);
        } catch (IOException x) {
            // should not happen - we passed 'false' above
            throw new UncheckedIOException(x);
        }
    }
}
 
Example 9
Project: influx-jmh-reporter   File: JMHJsonParserTest.java   View source code 6 votes vote down vote up
private static String getResourceAsString(final String resourceName)
{
    final StringBuilder stringBuilder = new StringBuilder();
    final InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resourceName);

    try
    {
        int read;
        while ((read = resourceAsStream.read()) != -1)
        {
            final char aByte = (char)read;
            stringBuilder.append(aByte);
        }

    }
    catch (final IOException e)
    {
        throw new UncheckedIOException(e);
    }
    return stringBuilder.toString();
}
 
Example 10
Project: Matcher   File: MappingWriter.java   View source code 6 votes vote down vote up
@Override
public void acceptClassComment(String srcName, String comment) {
	try {
		switch (format) {
		case TINY:
		case TINY_GZIP:
			writer.write("CLS-CMT\t");
			writer.write(srcName);
			writer.write('\t');
			writer.write(escape(comment));
			writer.write('\n');
			break;
		case SRG:
			// not supported
			break;
		case ENIGMA:
			enigmaState.acceptClassComment(srcName, comment);
			break;
		}
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
Example 11
Project: openjdk-jdk10   File: Loader.java   View source code 6 votes vote down vote up
@Override
public Stream<URL> resources(String name) {
    Objects.requireNonNull(name);
    // ordering not specified
    int characteristics = (Spliterator.NONNULL | Spliterator.IMMUTABLE |
                           Spliterator.SIZED | Spliterator.SUBSIZED);
    Supplier<Spliterator<URL>> supplier = () -> {
        try {
            List<URL> urls = findResourcesAsList(name);
            return Spliterators.spliterator(urls, characteristics);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    };
    Stream<URL> s1 = StreamSupport.stream(supplier, characteristics, false);
    Stream<URL> s2 = parent.resources(name);
    return Stream.concat(s1, s2);
}
 
Example 12
Project: Dayflower-Path-Tracer   File: CompiledScene.java   View source code 6 votes vote down vote up
public static CompiledScene read(final Camera camera, final DataInputStream dataInputStream) {
	try {
		final String name = dataInputStream.readUTF();
		
		final float[] boundingVolumeHierarchy = doReadFloatArray(dataInputStream);
		final float[] cameraArray = doReadFloatArray(dataInputStream, camera.getArray());
		final float[] point2s = doReadFloatArray(dataInputStream);
		final float[] point3s = doReadFloatArray(dataInputStream);
		final float[] shapes = doReadFloatArray(dataInputStream);
		final float[] surfaces = doReadFloatArray(dataInputStream);
		final float[] textures = doReadFloatArray(dataInputStream);
		final float[] vector3s = doReadFloatArray(dataInputStream);
		final int[] shapeOffsets = doReadIntArray(dataInputStream);
		
		return new CompiledScene(boundingVolumeHierarchy, cameraArray, point2s, point3s, shapes, surfaces, textures, vector3s, shapeOffsets, name);
	} catch(final IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
Example 13
Project: Dayflower-Path-Tracer   File: CompiledScene.java   View source code 6 votes vote down vote up
public void write(final DataOutputStream dataOutputStream) {
	try {
		dataOutputStream.writeUTF(this.name);
		
		doWriteFloatArray(dataOutputStream, this.boundingVolumeHierarchy);
		doWriteFloatArray(dataOutputStream, this.camera);
		doWriteFloatArray(dataOutputStream, this.point2s);
		doWriteFloatArray(dataOutputStream, this.point3s);
		doWriteFloatArray(dataOutputStream, this.shapes);
		doWriteFloatArray(dataOutputStream, this.surfaces);
		doWriteFloatArray(dataOutputStream, this.textures);
		doWriteFloatArray(dataOutputStream, this.vector3s);
		doWriteIntArray(dataOutputStream, this.shapeOffsets);
	} catch(final IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
Example 14
Project: openjdk-jdk10   File: DummyWebSocketServer.java   View source code 6 votes vote down vote up
private boolean readRequest(SocketChannel channel, StringBuilder request)
        throws IOException
{
    ByteBuffer buffer = ByteBuffer.allocate(512);
    int num = channel.read(buffer);
    if (num == -1) {
        return false;
    }
    CharBuffer decoded;
    buffer.flip();
    try {
        decoded = ISO_8859_1.newDecoder().decode(buffer);
    } catch (CharacterCodingException e) {
        throw new UncheckedIOException(e);
    }
    request.append(decoded);
    return Pattern.compile("\r\n\r\n").matcher(request).find();
}
 
Example 15
Project: carnotzet   File: ResourcesManager.java   View source code 6 votes vote down vote up
/**
 * Copies the resources from the specified module that affects itself. Resources that affect dependencies of the
 * specified module are not copied.
 */
private void copyOwnResources(List<CarnotzetModule> processedModules, CarnotzetModule module) throws IOException {
	Path expandedJarPath = expandedJars.resolve(module.getName());
	Path resolvedModulePath = resolved.resolve(module.getServiceId());
	if (!resolvedModulePath.toFile().exists() && !resolvedModulePath.toFile().mkdirs()) {
		throw new CarnotzetDefinitionException("Could not create directory " + resolvedModulePath);
	}

	// copy all regular files at the root of the expanded jar (such as carnotzet.properties)
	// copy all directories that do not reconfigure another module from the expanded jar recursively
	Files.find(expandedJarPath, 1, isRegularFile().or(nameMatchesModule(processedModules).negate()))
			.forEach(source -> {
				try {
					if (Files.isRegularFile(source)) {
						Files.copy(source, resolvedModulePath.resolve(source.getFileName()), StandardCopyOption.REPLACE_EXISTING);
					} else if (Files.isDirectory(source)) {
						FileUtils.copyDirectory(source.toFile(), resolvedModulePath.resolve(source.getFileName()).toFile());
					}
				}
				catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			});
}
 
Example 16
Project: metamodel-membrane   File: FileBasedDataSourceRegistry.java   View source code 6 votes vote down vote up
@Override
public DataContext openDataContext(String dataSourceName) throws NoSuchDataSourceException {
    if (Strings.isNullOrEmpty(dataSourceName)) {
        throw new IllegalArgumentException("DataSource name cannot be null or empty");
    }
    final File file = getDataSourceFile(dataSourceName);
    if (!file.exists()) {
        throw new NoSuchDataSourceException(dataSourceName);
    }

    final RestDataSourceDefinition dataSource;
    try {
        dataSource = OBJECT_MAPPER.readValue(file, RestDataSourceDefinition.class);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    final DataContextSupplier supplier =
            new DataContextSupplier(dataSourceName, dataSource.toDataContextProperties());
    return supplier.get();
}
 
Example 17
Project: app-ms   File: SwaggerCollator.java   View source code 6 votes vote down vote up
private void processUris(final Map<String, Path> swagger,
    final Map<String, Model> definitionsMap,
    final Map<String, SecuritySchemeDefinition> securityDefinitionsMap,
    final int i) {

    int j = 0;
    while (env.containsProperty(String.format("swagger[%d].uris[%d].swagger", i, j))) {
        try {
            final URL swaggerUrl = env.getProperty(String.format("swagger[%d].uris[%d].swagger", i, j), URL.class);

            final Swagger remoteSwagger = io.swagger.util.Json.mapper().readerFor(Swagger.class).readValue(swaggerUrl.openConnection().getInputStream());

            processPaths(swagger, definitionsMap, securityDefinitionsMap, remoteSwagger, i, j);
            ++j;
        } catch (final IOException e) {
            throw new UncheckedIOException(e);
        }

    }

}
 
Example 18
Project: openjdk-jdk10   File: HashesTest.java   View source code 6 votes vote down vote up
private void makeJar(String moduleName, String... options) {
    Path mclasses = mods.resolve(moduleName);
    Path outfile = lib.resolve(moduleName + ".jar");
    List<String> args = new ArrayList<>();
    Stream.concat(Stream.of("--create",
                            "--file=" + outfile.toString()),
                  Arrays.stream(options))
          .forEach(args::add);
    args.add("-C");
    args.add(mclasses.toString());
    args.add(".");

    if (Files.exists(outfile)) {
        try {
            Files.delete(outfile);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    int rc = JAR_TOOL.run(System.out, System.out, args.toArray(new String[args.size()]));
    System.out.println("jar " + args.stream().collect(Collectors.joining(" ")));
    if (rc != 0) {
        throw new AssertionError("jar failed: rc = " + rc);
    }
}
 
Example 19
Project: openjdk-jdk10   File: Archive.java   View source code 6 votes vote down vote up
public static boolean isSameLocation(Archive archive, Archive other) {
    if (archive.path == null || other.path == null)
        return false;

    if (archive.location != null && other.location != null &&
            archive.location.equals(other.location)) {
        return true;
    }

    if (archive.isJrt() || other.isJrt()) {
        return false;
    }

    try {
        return Files.isSameFile(archive.path, other.path);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 20
Project: openjdk-jdk10   File: ModulePatcher.java   View source code 6 votes vote down vote up
/**
 * Creates the ModuleReader to reads resources in a patched module.
 */
PatchedModuleReader(List<Path> patches, ModuleReference mref) {
    List<ResourceFinder> finders = new ArrayList<>();
    boolean initialized = false;
    try {
        for (Path file : patches) {
            if (Files.isRegularFile(file)) {
                finders.add(new JarResourceFinder(file));
            } else {
                finders.add(new ExplodedResourceFinder(file));
            }
        }
        initialized = true;
    } catch (IOException ioe) {
        throw new UncheckedIOException(ioe);
    } finally {
        // close all ResourceFinder in the event of an error
        if (!initialized) closeAll(finders);
    }

    this.finders = finders;
    this.mref = mref;
    this.delegateCodeSourceURL = codeSourceURL(mref);
}
 
Example 21
Project: core-ng-demo-project   File: InputStreamsBenchmark.java   View source code 6 votes vote down vote up
private static byte[] bytesOldVersion(InputStream stream, int initialCapacity) {
    byte[] bytes = new byte[initialCapacity];
    int position = 0;
    try {
        while (true) {
            int bytesToRead = bytes.length - position;
            int bytesRead = stream.read(bytes, position, bytesToRead);
            if (bytesRead < 0) break;
            position += bytesRead;
            if (position >= bytes.length) {
                byte[] newBytes = new byte[bytes.length * 2];
                System.arraycopy(bytes, 0, newBytes, 0, position);
                bytes = newBytes;
            }
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    byte[] result = new byte[position];
    System.arraycopy(bytes, 0, result, 0, position);
    return result;
}
 
Example 22
Project: elasticsearch_my   File: Script.java   View source code 6 votes vote down vote up
/**
 * Since inline scripts can accept code rather than just an id, they must also be able
 * to handle template parsing, hence the need for custom parsing code.  Templates can
 * consist of either an {@link String} or a JSON object.  If a JSON object is discovered
 * then the content type option must also be saved as a compiler option.
 */
private void setInline(XContentParser parser) {
    try {
        if (type != null) {
            throwOnlyOneOfType();
        }

        type = ScriptType.INLINE;

        if (parser.currentToken() == Token.START_OBJECT) {
            //this is really for search templates, that need to be converted to json format
            XContentBuilder builder = XContentFactory.jsonBuilder();
            idOrCode = builder.copyCurrentStructure(parser).string();
            options.put(CONTENT_TYPE_OPTION, XContentType.JSON.mediaType());
        } else {
            idOrCode = parser.text();
        }
    } catch (IOException exception) {
        throw new UncheckedIOException(exception);
    }
}
 
Example 23
Project: setra   File: FileDiskRepository.java   View source code 6 votes vote down vote up
@Scheduled(fixedDelay = 900_000)
private void cleanup() {
    LOG.info("Starting file cleanup Job");

    final Instant now = Instant.now();

    int messageCnt = 0;
    for (final Iterator<Map.Entry<String, SecretFile>> it = files.entrySet().iterator();
         it.hasNext();) {

        final Map.Entry<String, SecretFile> entry = it.next();

        if (now.isAfter(entry.getValue().getExpiration())) {
            try {
                burnFile(entry.getKey());
            } catch (final UncheckedIOException e) {
                LOG.error("Error deleting file {}", entry.getKey(), e);
            }
            it.remove();
            messageCnt++;
        }
    }

    LOG.info("Cleaned up {} files", messageCnt);
}
 
Example 24
Project: openjdk-jdk10   File: SJFM_TestBase.java   View source code 6 votes vote down vote up
/**
 * Create a zip file containing the contents of the test.src directory.
 *
 * @return a path for the zip file.
 * @throws IOException if there is a problem creating the file
 */
private Path createSourceZip() throws IOException {
    Path testSrc = Paths.get(System.getProperty("test.src"));
    Path testZip = Paths.get("test.zip");
    try (OutputStream os = Files.newOutputStream(testZip)) {
        try (ZipOutputStream zos = new ZipOutputStream(os)) {
            Files.list(testSrc)
                .filter(p -> p.getFileName().toString().endsWith(".java"))
                .forEach(p -> {
                    try {
                        zos.putNextEntry(new ZipEntry(p.getFileName().toString()));
                        zos.write(Files.readAllBytes(p));
                        zos.closeEntry();
                    } catch (IOException ex) {
                        throw new UncheckedIOException(ex);
                    }
                });
        }
    }
    return testZip;
}
 
Example 25
Project: openjdk-jdk10   File: ICUBinary.java   View source code 6 votes vote down vote up
/**
 * Loads an ICU binary data file and returns it as a ByteBuffer.
 * The buffer contents is normally read-only, but its position etc. can be modified.
 *
 * @param itemPath Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".
 * @return The data as a read-only ByteBuffer.
 */
public static ByteBuffer getRequiredData(String itemPath) {
    final Class<ICUBinary> root = ICUBinary.class;

    try (InputStream is = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
            public InputStream run() {
                return root.getResourceAsStream(itemPath);
            }
        })) {

        BufferedInputStream b=new BufferedInputStream(is, 4096 /* data buffer size */);
        DataInputStream inputStream = new DataInputStream(b);
        byte[] bb = new byte[120000];
        int n = inputStream.read(bb);
        ByteBuffer bytes = ByteBuffer.wrap(bb, 0, n);
        return bytes;
    }
    catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 26
Project: setra   File: AbstractDiskMessageRepository.java   View source code 6 votes vote down vote up
@Scheduled(fixedDelay = 900_000)
private void cleanup() {
    log.info("Starting message cleanup Job");

    final Instant now = Instant.now();

    int messageCnt = 0;
    for (final Iterator<Map.Entry<String, Instant>> it = messages.entrySet().iterator();
         it.hasNext();) {

        final Map.Entry<String, Instant> entry = it.next();

        if (now.isAfter(entry.getValue())) {
            try {
                delete(entry.getKey());
            } catch (final UncheckedIOException e) {
                log.error("Error deleting file {}", entry.getKey(), e);
            }
            it.remove();
            messageCnt++;
        }
    }

    log.info("Cleaned up {} messages", messageCnt);
}
 
Example 27
Project: openjdk-jdk10   File: StreamTest.java   View source code 5 votes vote down vote up
private void checkMalformedInputException(Stream<String> s) {
    try {
        List<String> lines = s.collect(Collectors.toList());
        fail("UncheckedIOException expected");
    } catch (UncheckedIOException ex) {
        IOException cause = ex.getCause();
        assertTrue(cause instanceof MalformedInputException,
            "MalformedInputException expected");
    }
}
 
Example 28
Project: setra   File: FileMemoryRepository.java   View source code 5 votes vote down vote up
@Override
public InputStream getStoredFileInputStream(final String id, final KeyIv key) {
    LOG.info("Get stream for file {}", id);
    try {
        return cryptor.getCryptIn(new ByteArrayInputStream(data.get(id)),
            key);
    } catch (final IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 29
Project: multiple-dimension-spread   File: OptimizeDumpStringColumnBinaryMaker.java   View source code 5 votes vote down vote up
@Override
public IColumn get(){
  try{
    create();
  }catch( IOException e ){
    throw new UncheckedIOException( e );
  }
  return column;
}
 
Example 30
Project: pipeline-github   File: PullRequestGroovyObject.java   View source code 5 votes vote down vote up
private void setBase(final String newBase) {
    ExtendedPullRequest edit = new ExtendedPullRequest();
    edit.setNumber(pullRequest.getNumber());
    edit.setBase(new PullRequestMarker().setRef(newBase));
    try {
        pullRequest = pullRequestService.editPullRequest(base, edit);
    } catch (final IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 31
Project: Parseux   File: CsvAsDTOTest.java   View source code 5 votes vote down vote up
@Test(expected = UncheckedIOException.class)
public void throwExceptionTrailingComma() {
    new CsvAsDTO<>(
        new InputStreamReader(
            new ResourceAsStream("csv/test-trail-comma.csv").stream()
        ),
        CsvTestDTO.class
    ).asDTOs();
}
 
Example 32
Project: multiple-dimension-spread   File: BufferDirectCellManager.java   View source code 5 votes vote down vote up
@Override
public void setPrimitiveObjectArray(final IExpressionIndex indexList , final int start , final int length , final IMemoryAllocator allocator ){
  int loopEnd = ( start + length );
  if( indexList.size() < loopEnd ){
    loopEnd = indexList.size();
  }
  try{
    int index = 0;
    for( int i = start ; i < loopEnd ; i++,index++ ){
      int targetIndex = indexList.get( i );
      if( indexSize <= targetIndex ){
        break;
      }
      PrimitiveObject obj = dicManager.get( targetIndex );
      if( obj == null ){
        allocator.setNull( index );
      }
      else{
        allocator.setPrimitiveObject( index , obj );
      }
    }
    for( int i = index ; i < length ; i++ ){
      allocator.setNull( i );
    }
  }catch( IOException e ){
    throw new UncheckedIOException( e );
  }
}
 
Example 33
Project: openjdk-jdk10   File: TestDriver.java   View source code 5 votes vote down vote up
private void copyDirectories(Path source, Path dest) throws IOException {
    if (Files.exists(dest))
        FileUtils.deleteFileTreeWithRetry(dest);
    Files.walk(source, Integer.MAX_VALUE)
            .filter(Files::isRegularFile)
            .forEach(p -> {
                try {
                    Path to = dest.resolve(source.relativize(p));
                    Files.createDirectories(to.getParent());
                    Files.copy(p, to);
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            });
}
 
Example 34
Project: openjdk-jdk10   File: FieldSetAccessibleTest.java   View source code 5 votes vote down vote up
@Override
public Iterator<String> iterator() {
    try {
        return Files.walk(root)
                .filter(p -> p.getNameCount() > 2)
                .filter(p -> modules.contains(p.getName(1).toString()))
                .map(p -> p.subpath(2, p.getNameCount()))
                .map(p -> p.toString())
                .filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class"))
            .iterator();
    } catch(IOException x) {
        throw new UncheckedIOException("Unable to walk \"/modules\"", x);
    }
}
 
Example 35
Project: influx-jmh-reporter   File: FileReader.java   View source code 5 votes vote down vote up
String readFile(final String file)
{
    try
    {
        return new String(Files.readAllBytes(Paths.get(file)), StandardCharsets.US_ASCII);
    }
    catch (final IOException e)
    {
        throw new UncheckedIOException(e);
    }
}
 
Example 36
Project: multiple-dimension-spread   File: DumpBooleanColumnBinaryMaker.java   View source code 5 votes vote down vote up
@Override
public IColumn get(){
  try{
    create();
  }catch( IOException e ){
    throw new UncheckedIOException( e );
  }
  return column;
}
 
Example 37
Project: openjdk-jdk10   File: DefaultImageBuilder.java   View source code 5 votes vote down vote up
/**
 * chmod ugo+x file
 */
private void setExecutable(Path file) {
    try {
        Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file);
        perms.add(PosixFilePermission.OWNER_EXECUTE);
        perms.add(PosixFilePermission.GROUP_EXECUTE);
        perms.add(PosixFilePermission.OTHERS_EXECUTE);
        Files.setPosixFilePermissions(file, perms);
    } catch (IOException ioe) {
        throw new UncheckedIOException(ioe);
    }
}
 
Example 38
Project: aws-sdk-java-v2   File: ApacheUtils.java   View source code 5 votes vote down vote up
/**
 * Utility function for creating a new BufferedEntity and wrapping any errors
 * as a SdkClientException.
 *
 * @param entity The HTTP entity to wrap with a buffered HTTP entity.
 * @return A new BufferedHttpEntity wrapping the specified entity.
 */
public static HttpEntity newBufferedHttpEntity(HttpEntity entity) {
    try {
        return new BufferedHttpEntity(entity);
    } catch (IOException e) {
        throw new UncheckedIOException("Unable to create HTTP entity: " + e.getMessage(), e);
    }
}
 
Example 39
Project: cactoos   File: UncheckedProcTest.java   View source code 5 votes vote down vote up
@Test(expected = UncheckedIOException.class)
public void rethrowsCheckedToUncheckedException() {
    new UncheckedProc<>(
        input -> {
            throw new IOException("intended");
        }
    ).exec(1);
}
 
Example 40
Project: catalysts_coding_contest_template   File: InputReaderImpl.java   View source code 5 votes vote down vote up
@Override
public String readLine() {
	try {
		return bufferedReader.readLine();
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}