List of usage examples for java.lang IllegalStateException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.github.horrorho.inflatabledonkey.cloud.Donkey.java
public void apply(HttpClient httpClient, Optional<ForkJoinPool> aux, Set<Asset> assets, FileAssembler consumer) {/*from w ww . j a v a2s . co m*/ logger.trace("<< apply() - assets: {}", assets.size()); if (assets.isEmpty()) { return; } if (logger.isDebugEnabled()) { int bytes = assets.stream().mapToInt(u -> u.size().map(Long::intValue).orElse(0)).sum(); logger.debug("-- apply() - assets total: {} size (bytes): {}", assets.size(), bytes); } AssetPool pool = new AssetPool(assets); while (true) { try { if (assets.size() > fragmentationThreshold && aux.isPresent()) { processConcurrent(httpClient, aux.get(), pool, consumer); } else { process(httpClient, pool, consumer); } break; } catch (IllegalStateException ex) { // Our StorageHostChunkLists have expired. // TOFIX potentially unsafe. Use a more specific exception. logger.debug("-- apply() - IllegalStateException: {}", ex.getMessage()); } catch (IllegalArgumentException | IOException ex) { logger.warn("-- apply() - {} {}", ex.getClass().getCanonicalName(), ex.getMessage()); break; } } logger.trace(">> apply() - pool empty: {}", pool.isEmpty()); }
From source file:org.olat.core.gui.media.ServletUtil.java
private static void serveFullResource(HttpServletRequest httpReq, HttpServletResponse httpResp, MediaResource mr) {/* w w w. jav a 2 s. c o m*/ boolean debug = log.isDebug(); InputStream in = null; OutputStream out = null; BufferedInputStream bis = null; try { Long size = mr.getSize(); Long lastModified = mr.getLastModified(); //fxdiff FXOLAT-118: accept range to deliver videos for iPad (implementation based on Tomcat) List<Range> ranges = parseRange(httpReq, httpResp, (lastModified == null ? -1 : lastModified.longValue()), (size == null ? 0 : size.longValue())); if (ranges != null && mr.acceptRanges()) { httpResp.setHeader("Accept-Ranges", "bytes"); } // maybe some more preparations mr.prepare(httpResp); in = mr.getInputStream(); // serve the Resource if (in != null) { long rstart = 0; if (debug) { rstart = System.currentTimeMillis(); } if (Settings.isDebuging()) { SlowBandWidthSimulator sbs = Windows .getWindows(CoreSpringFactory.getImpl(UserSessionManager.class).getUserSession(httpReq)) .getSlowBandWidthSimulator(); out = sbs.wrapOutputStream(httpResp.getOutputStream()); } else { out = httpResp.getOutputStream(); } if (ranges != null && ranges.size() == 1) { Range range = ranges.get(0); httpResp.addHeader("Content-Range", "bytes " + range.start + "-" + range.end + "/" + range.length); long length = range.end - range.start + 1; if (length < Integer.MAX_VALUE) { httpResp.setContentLength((int) length); } else { // Set the content-length as String to be able to use a long httpResp.setHeader("content-length", "" + length); } httpResp.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); try { httpResp.setBufferSize(2048); } catch (IllegalStateException e) { // Silent catch } copy(out, in, range); } else { if (size != null) { httpResp.setContentLength(size.intValue()); } // buffer input stream bis = new BufferedInputStream(in); IOUtils.copy(bis, out); } if (debug) { long rstop = System.currentTimeMillis(); log.debug("time to serve (mr=" + mr.getClass().getName() + ") " + (size == null ? "n/a" : "" + size) + " bytes: " + (rstop - rstart)); } } } catch (IOException e) { FileUtils.closeSafely(out); String className = e.getClass().getSimpleName(); if ("ClientAbortException".equals(className)) { log.warn("client browser probably abort when serving media resource", e); } else { log.error("client browser probably abort when serving media resource", e); } } finally { IOUtils.closeQuietly(bis); IOUtils.closeQuietly(in); } }
From source file:de.tudarmstadt.lt.n2n.annotators.RelationAnnotator.java
private void searchForPath(JCas aJCas) { List<Relation> relations_to_remove = new LinkedList<Relation>(); for (Relation relation : JCasUtil.select(aJCas, Relation.class)) { Entity e1 = relation.getE1(); Entity e2 = relation.getE2(); Sentence covering_sentence = relation.getCoveringSentence(); LOG.trace(// ww w .j a va 2s .c om "searching for a shortest path in the dependency graph for relation ({}-{},{}-{}) in sentence [{}].", e1.getCoveredText(), e1.getBegin(), e2.getCoveredText(), e2.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50)); List<Dependency> dependency_path = null; try { dependency_path = find_path(e1, e2, JCasUtil.selectCovered(Dependency.class, covering_sentence)); if (dependency_path == null) { // no path found relations_to_remove.add(relation); LOG.debug("Removing relation ({}-{},{}-{}) in sentence [{}]. No dependency path was found.", e1.getCoveredText(), e1.getBegin(), e2.getCoveredText(), e2.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50)); continue; } } catch (IllegalStateException e) { relations_to_remove.add(relation); LOG.warn(String.format("%s: '%s.'", e.getClass().getSimpleName(), e.getMessage())); continue; } int path_length = dependency_path.size(); // dependencies are edges thus the path length is len(edges) LOG.trace("Found shortest path with length {} for relation ({}-{},{}-{}) in sentence [{}].", path_length, e1.getCoveredText(), e1.getBegin(), e2.getCoveredText(), e2.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50)); // if the direct neighbor of either entities representative tokens is connected via 'nn' relation and the representative token is not the governor then ignore this edge if (_remove_immediate_nn_relations) { if (path_length > 0 && "nn".equals(dependency_path.get(0).getDependencyType()) && dependency_path.get(0).getDependent().equals(e1.getRepresentativeToken())) { // check first edge dependency_path.remove(0); path_length--; LOG.debug( "The immediate connecting edge for e1 ({}-{}) in sentence [{}] is an 'nn' relation and e1 is the dependent. It is removed from the path. New path length is {}.", e1.getCoveredText(), e1.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50), path_length); } if (path_length > 0 && "nn".equals(dependency_path.get(path_length - 1).getDependencyType()) && dependency_path.get(path_length - 1).getDependent() .equals(e2.getRepresentativeToken())) { // check last edge dependency_path.remove(path_length - 1); path_length--; LOG.debug( "The immediate connecting edge for e2 ({}-{}) in sentence [{}] is an 'nn' relation and e1 is the dependent. It is removed from the path. New path length is {}.", e2.getCoveredText(), e2.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50), path_length); } } // if path is too short skip it if (path_length < _min_dependency_path_length) { LOG.debug( "Path for relation ({}-{},{}-{}) in sentence [{}] is shorter than minlength={} ({}). Removing relation from cas index.", e1.getCoveredText(), e1.getBegin(), e2.getCoveredText(), e2.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50), _min_dependency_path_length, path_length); relations_to_remove.add(relation); continue; } // if path is too long skip it if (path_length > _max_dependency_path_length) { LOG.debug( "Path for relation ({}-{},{}-{}) in sentence [{}] is longer than maxlength={} ({}). Removing relation from cas index.", e1.getCoveredText(), e1.getBegin(), e2.getCoveredText(), e2.getBegin(), StringUtils.abbreviate(covering_sentence.getCoveredText(), 50), _max_dependency_path_length, path_length); relations_to_remove.add(relation); continue; } relation.setDependencyPath((FSArray) aJCas.getCas().createArrayFS(dependency_path.size())); for (int i = 0; i < dependency_path.size(); i++) relation.setDependencyPath(i, dependency_path.get(i)); } for (Relation relation : relations_to_remove) relation.removeFromIndexes(aJCas); }
From source file:edu.vt.middleware.ldap.pool.LdapPoolTest.java
/** @throws Exception On test failure. */ @Test(groups = { "softlimitpooltest" }) public void checkSoftLimitPoolImmutable() throws Exception { try {//from w ww. ja v a 2s. co m this.softLimitPool.getLdapPoolConfig().setMinPoolSize(8); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } Ldap ldap = null; try { ldap = this.softLimitPool.checkOut(); try { ldap.setLdapConfig(new LdapConfig()); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } try { ldap.getLdapConfig().setTimeout(10000); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } } finally { this.softLimitPool.checkIn(ldap); } }
From source file:edu.vt.middleware.ldap.pool.LdapPoolTest.java
/** @throws Exception On test failure. */ @Test(groups = { "blockingpooltest" }) public void checkBlockingPoolImmutable() throws Exception { try {/*from w w w .ja v a 2 s.c om*/ this.blockingPool.getLdapPoolConfig().setMinPoolSize(8); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } Ldap ldap = null; try { ldap = this.blockingPool.checkOut(); try { ldap.setLdapConfig(new LdapConfig()); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } try { ldap.getLdapConfig().setTimeout(10000); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } } finally { this.blockingPool.checkIn(ldap); } }
From source file:edu.vt.middleware.ldap.pool.LdapPoolTest.java
/** @throws Exception On test failure. */ @Test(groups = { "sharedpooltest" }) public void checkSharedPoolImmutable() throws Exception { try {//from www . j av a2s .c o m this.sharedPool.getLdapPoolConfig().setMinPoolSize(8); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } Ldap ldap = null; try { ldap = this.sharedPool.checkOut(); try { ldap.setLdapConfig(new LdapConfig()); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } try { ldap.getLdapConfig().setTimeout(10000); AssertJUnit.fail("Expected illegalstateexception to be thrown"); } catch (IllegalStateException e) { AssertJUnit.assertEquals(IllegalStateException.class, e.getClass()); } } finally { this.sharedPool.checkIn(ldap); } }
From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java
/** * testResolveCollectionType09() <br> * <br>/* w w w.j av a2 s .c om*/ * () <br> * G <br> * <br> * () bean:int integer?????getter??<br> * () name:"integer"<br> * <br> * () :IllegalStateException<br> * <br> * ??????IllegalStateException?????? <br> * @throws Exception ????? */ @Test public void testResolveCollectionType09() throws Exception { try { // GenericPropertyUtil.resolveCollectionType(new GenericPropertyUtil_Stub01(), "integer"); // fail("???????"); } catch (IllegalStateException e) { assertEquals(IllegalStateException.class.getName(), e.getClass().getName()); } }
From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java
/** * testResolveCollectionType10() <br> * <br>//w w w . j a va 2s .com * () <br> * G <br> * <br> * () bean:Object object?????getter??<br> * () name:"object"<br> * <br> * () :IllegalStateException<br> * <br> * ???Collection????IllegalStateException?????? <br> * @throws Exception ????? */ @Test public void testResolveCollectionType10() throws Exception { try { // GenericPropertyUtil.resolveCollectionType(new GenericPropertyUtil_Stub01(), "object"); // fail("???????"); } catch (IllegalStateException e) { assertEquals(IllegalStateException.class.getName(), e.getClass().getName()); } }
From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java
/** * testResolveTypeObjectStringClassint13() <br> * <br>/* w w w . j a v a2 s . com*/ * <br> * G <br> * <br> * () bean:Map<String[], List<String>> map2????getter??<br> * () name:"map2"<br> * () genericClass:String.class<br> * () index:1<br> * <br> * () :IllegalStateException<br> * <br> * genericClass????????? IllegalStateException?????? <br> * @throws Exception ????? */ @Test public void testResolveTypeObjectStringClassint13() throws Exception { try { // GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "map2", String.class, 1); // fail("???????"); } catch (IllegalStateException e) { assertEquals(IllegalStateException.class.getName(), e.getClass().getName()); } }
From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java
/** * testResolveTypeObjectStringClassint14() <br> * <br>/*from www. jav a 2s .c om*/ * <br> * G <br> * <br> * () bean:?int integer????getter??<br> * () name:"integer"<br> * () genericClass:int.class<br> * () index:1<br> * <br> * () :IllegalStateException<br> * "No parameterizedType was detected."<br> * <br> * ?????? IllegalStateException?????? <br> * @throws Exception ????? */ @Test public void testResolveTypeObjectStringClassint14() throws Exception { try { // GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "integer", int.class, 1); // fail("???????"); } catch (IllegalStateException e) { assertEquals("No parameterizedType was detected.", e.getMessage()); assertEquals(IllegalStateException.class.getName(), e.getClass().getName()); } }