@Override public void upgradeHTTP2(Request request, SettingsFrame settings, Promise<HTTP2ClientConnection> promise, ClientHTTPHandler upgradeHandler, ClientHTTPHandler http2ResponseHandler) { throw new CommonRuntimeException("The current connection version is http2, it does not need to upgrading."); }
@Override public void upgradeWebSocket(Request request, WebSocketPolicy policy, Promise<WebSocketConnection> promise, ClientHTTPHandler upgradeHandler, IncomingFrames incomingFrames) { throw new CommonRuntimeException("The current connection version is http2, it can not upgrade WebSocket."); }
@Override public void upgradeHTTP2(Request request, SettingsFrame settings, Promise<HTTP2ClientConnection> promise, ClientHTTPHandler upgradeHandler, ClientHTTPHandler http2ResponseHandler) { throw new CommonRuntimeException("The current connection version is http2, it does not need to upgrading."); }
private static Class<?> getClass(String name) { try { return Class.forName(name, false, classLoader); } catch (ClassNotFoundException e) { throw new CommonRuntimeException(e); } }
private static URI toURI(String name) { try { return new URI(name); } catch (URISyntaxException e) { throw new CommonRuntimeException(e); } }
private static URI toURI(String name) { try { return new URI(name); } catch (URISyntaxException e) { throw new CommonRuntimeException(e); } }
public DefaultDom() { try { db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new CommonRuntimeException(e); } }
public StaticResourceHandler() { try { Path path = Paths.get(SysRouterInstaller.class.getResource("/").toURI()); staticFileHandler = new StaticFileHandler(path.toAbsolutePath().toString()); } catch (Exception e) { throw new CommonRuntimeException(e); } }
private void shutdown() { try { shutdown = true; workQueue.put(new ShutdownCommand()); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } }
private void shutdown() { try { shutdown = true; workQueue.put(new ShutdownCommand()); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } }
public Object copyOf(List<Object> list) { Object ret = Array.newInstance(elementMetaInfo.getExtractedType(), list.size()); for (int i = 0; i < list.size(); i++) { try { ReflectUtils.arraySet(ret, i, list.get(i)); } catch (Throwable e) { throw new CommonRuntimeException(e); } } return ret; }
public static String toJson(Object obj) { try (JsonWriter writer = new JsonStringWriter()) { SerialStateMachine.toJson(obj, writer); return writer.toString(); } catch (IOException e) { throw new CommonRuntimeException(e); } }
public void invoke(Object obj, JsonReader reader) { try { propertyAccess.setValue(obj, getValue(reader)); } catch (Throwable e) { throw new CommonRuntimeException(e); } }
public static JsonObject toJsonObject(String json) { try (JsonReader reader = new JsonStringReader(json)) { return GeneralJSONObjectStateMacine.toJsonObject(reader); } catch (IOException e) { throw new CommonRuntimeException(e); } }
public void invoke(Object obj, JsonReader reader) { try { propertyAccess.setValue(obj, getValue(reader)); } catch (Throwable e) { throw new CommonRuntimeException(e); } }
@SuppressWarnings("unchecked") public static <T> T toObject(String json, Class<T> clazz) { try (JsonReader reader = new JsonStringReader(json)) { return (T) ParserStateMachine.toObject(reader, clazz, clazz); } catch (IOException e) { throw new CommonRuntimeException(e); } }
public static JsonArray toJsonArray(String json) { try (JsonReader reader = new JsonStringReader(json)) { return GeneralJSONObjectStateMacine.toJsonArray(reader); } catch (IOException e) { throw new CommonRuntimeException(e); } }
public static <T> T callInManagedBlock(final Supplier<T> supplier) { final SupplierManagedBlock<T> managedBlock = new SupplierManagedBlock<>(supplier); try { ForkJoinPool.managedBlock(managedBlock); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } return managedBlock.getResult(); }
@SuppressWarnings("unchecked") public static <T> T toObject(String json, Type type) { try (JsonReader reader = new JsonStringReader(json)) { Class<?> extractedClass = BeanUtils.extractClass(type); return (T) ParserStateMachine.toObject(reader, getImplClass(extractedClass), type); } catch (IOException e) { throw new CommonRuntimeException(e); } }
public static void main(String[] args) { $.httpServer().router().get("/error") .handler(ctx -> { throw new CommonRuntimeException("perhaps some errors happen"); }).listen("localhost", 8080); } }