void free() { open = false; buffers.forEach(ByteBufferUtils::free); buffers.clear(); headBufferIndex = -1; headBuffer = null; size = 0; capacity = 0; } }
private static Map<String, String> getHeaders(HttpServletRequest request) { Map<String, String> headers = new HashMap<>(); Collections.list(request.getHeaderNames()).forEach(header -> headers.put(header.toLowerCase(Locale.ENGLISH), request.getHeader(header))); return headers; }
public void executeRecorded() { ArrayList<Runnable> runnables = new ArrayList<>(runnableList); runnableList.clear(); runnables.forEach(Runnable::run); } }
/** * Read a svg file and return the svg element (original) and a new symbol element (created from * original). * * @param file Svg file. * @param id ID to use. * @return Svg element (original) and a symbol element (converted). * @throws IOException If something goes wrong. */ private Tuple<Element, Element> symbol(final Path file, final String id) throws IOException { Element svg = Jsoup.parse(file.toFile(), "UTF-8").select("svg").first(); Element symbol = new Element(Tag.valueOf("symbol"), "") .attr("id", id) .attr("viewBox", svg.attr("viewBox")); new ArrayList<>(svg.childNodes()).forEach(symbol::appendChild); return new Tuple(svg, symbol); }
new ArrayList<>(namedWorkerPools.values()).forEach(WorkerPool::close);
/** {@inheritDoc} */ @Override public void onLocalJoin(DiscoveryEvent evt, DiscoCache discoCache) { assert ctx.localNodeId().equals(evt.eventNode().id()); assert evt.type() == EVT_NODE_JOINED; if (isLocalNodeCoordinator()) { // First node start, method onGridDataReceived(DiscoveryDataBag.GridDiscoveryData) has not been called. ArrayList<ServiceInfo> staticServicesInfo = staticallyConfiguredServices(false); staticServicesInfo.forEach(desc -> registeredServices.put(desc.serviceId(), desc)); } ServiceDeploymentActions depActions = null; if (!registeredServices.isEmpty()) { depActions = new ServiceDeploymentActions(); depActions.servicesToDeploy(new HashMap<>(registeredServices)); } depMgr.onLocalJoin(evt, discoCache, depActions); }
private static void addLemmata(Tree tree) { tree.yield().forEach(l -> { CoreLabel w = (CoreLabel) l; if(w.lemma() == null) { w.setLemma(MORPH.lemma(w.word(), w.tag())); } }); }
private void executeLocal() { try { inetAddrs = new LinkedList<>(); Collections.list(NetworkInterface.getNetworkInterfaces()) .forEach(netInterface -> inetAddrs.addAll(Collections.list(netInterface.getInetAddresses()))); selectAddresses(); if (nameAddr != null && hasHostName(nameAddr)) { setDomainAndName(nameAddr.getCanonicalHostName()); } else { setProperty(DOMAIN, DEF_DOMAIN); setProperty(NAME, DEF_LOCAL_NAME); } if (best4 != null) { setProperty(ADDR4, best4.getHostAddress()); } else { setProperty(ADDR4, DEF_LOCAL_ADDR4); } if (best6 != null) { setProperty(ADDR6, best6.getHostAddress()); } else { setProperty(ADDR6, DEF_LOCAL_ADDR6); } } catch (Exception e) { log("Error retrieving local host information", e, Project.MSG_WARN); setProperty(DOMAIN, DEF_DOMAIN); setProperty(NAME, DEF_LOCAL_NAME); setProperty(ADDR4, DEF_LOCAL_ADDR4); setProperty(ADDR6, DEF_LOCAL_ADDR6); } }
warnings.add( "Multiple Class-Path attributes are supported but violate the Jar specification and may not be correctly processed in all environments"); Collections.list(attribute.getValues()).forEach(classpathAttribute::addValue);
/** * Remove the specified shape from this group */ @Override public boolean removeShape(XSLFShape xShape) { XmlObject obj = xShape.getXmlObject(); CTGroupShape grpSp = (CTGroupShape)getXmlObject(); getSheet().deregisterShapeId(xShape.getShapeId()); if(obj instanceof CTShape){ grpSp.getSpList().remove(obj); } else if (obj instanceof CTGroupShape){ XSLFGroupShape gs = (XSLFGroupShape)xShape; new ArrayList<>(gs.getShapes()).forEach(gs::removeShape); grpSp.getGrpSpList().remove(obj); } else if (obj instanceof CTConnector){ grpSp.getCxnSpList().remove(obj); } else if (obj instanceof CTGraphicalObjectFrame) { grpSp.getGraphicFrameList().remove(obj); } else if (obj instanceof CTPicture) { XSLFPictureShape ps = (XSLFPictureShape)xShape; XSLFSheet sh = getSheet(); if (sh != null) { sh.removePictureRelation(ps); } grpSp.getPicList().remove(obj); } else { throw new IllegalArgumentException("Unsupported shape: " + xShape); } return _shapes.remove(xShape); }
} else if (obj instanceof CTGroupShape) { XSLFGroupShape gs = (XSLFGroupShape)xShape; new ArrayList<>(gs.getShapes()).forEach(gs::removeShape); spTree.getGrpSpList().remove(obj); } else if (obj instanceof CTConnector) {
@Test public void testHttpClientMetricsQueueClose() throws Exception { server = vertx.createHttpServer(); List<Runnable> requests = Collections.synchronizedList(new ArrayList<>()); server.requestHandler(req -> { requests.add(() -> { vertx.runOnContext(v -> { req.connection().close(); }); }); }); CountDownLatch listenLatch = new CountDownLatch(1); server.listen(8080, "localhost", onSuccess(s -> { listenLatch.countDown(); })); awaitLatch(listenLatch); client = vertx.createHttpClient(); FakeHttpClientMetrics metrics = FakeHttpClientMetrics.getMetrics(client); for (int i = 0;i < 5;i++) { client.getNow(8080, "localhost", "/somepath", resp -> { }); } assertWaitUntil(() -> requests.size() == 5); EndpointMetric endpoint = metrics.endpoint("localhost:8080"); assertEquals(5, endpoint.connectionCount.get()); ArrayList<Runnable> copy = new ArrayList<>(requests); requests.clear(); copy.forEach(Runnable::run); assertWaitUntil(() -> metrics.endpoints().isEmpty()); assertEquals(0, endpoint.connectionCount.get()); }
/** * Get a description handler. * @param srcDir the source directory. * @return the handler. */ protected DescriptorHandler getWebsphereDescriptorHandler(final File srcDir) { DescriptorHandler handler = new DescriptorHandler(getTask(), srcDir) { @Override protected void processElement() { } }; getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation())); return handler; }
/** {@inheritDoc}. */ @Override protected DescriptorHandler getDescriptorHandler(File srcDir) { DescriptorHandler handler = new DescriptorHandler(getTask(), srcDir); // register all the DTDs, both the ones that are known and // any supplied by the user handler.registerDTD(PUBLICID_EJB11, ejb11DTD); getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation())); return handler; }
vertx.setTimer(300, v -> { assertEquals(maxRequests, requests.size()); requests.forEach(r -> r.response().end()); });
ArrayList<Runnable> copy = new ArrayList<>(requests); requests.clear(); copy.forEach(Runnable::run); awaitLatch(responsesLatch); assertWaitUntil(() -> requests.size() == 5); copy = new ArrayList<>(requests); requests.clear(); copy.forEach(Runnable::run); assertWaitUntil(() -> requests.size() == 3); assertEquals(Collections.singleton("localhost:8080"), metrics.endpoints());
handler.registerDTD(PUBLICID_WEBLOGIC_EJB600, weblogicDTD); getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation())); return handler;