public final URI toUri() { URI zdirURI = this.getArchiveURI(); try { // Optimistic try and see return new URI("jar:" + zdirURI.toString() + "!/" + resName); // NOI18N } catch (URISyntaxException e) { // Need to encode the resName part (slower) final StringBuilder sb = new StringBuilder(); final String[] elements = resName.split("/"); // NOI18N try { for (int i = 0; i < elements.length; i++) { String element = elements[i]; element = URLEncoder.encode(element, "UTF-8"); // NOI18N element = element.replace("+", "%20"); // NOI18N sb.append(element); if (i < elements.length - 1) { sb.append('/'); // NOI18N } } return new URI("jar:" + zdirURI.toString() + "!/" + sb.toString()); // NOI18N } catch (final UnsupportedEncodingException e2) { final IllegalStateException ne = new IllegalStateException(); ne.initCause(e2); throw ne; } catch (final URISyntaxException e2) { final IllegalStateException ne = new IllegalStateException(); ne.initCause(e2); throw ne; } } }
private void doForward(String relativeUrlPath) throws ServletException, IOException { // JSP.4.5 If the buffer was flushed, throw IllegalStateException try { out.clear(); } catch (IOException ex) { IllegalStateException ise = new IllegalStateException( Localizer.getMessage("jsp.error.attempt_to_clear_flushed_buffer")); ise.initCause(ex); throw ise; } // Make sure that the response object is not the wrapper for include while (response instanceof ServletResponseWrapperInclude) { response = ((ServletResponseWrapperInclude) response).getResponse(); } final String path = getAbsolutePathRelativeToContext(relativeUrlPath); String includeUri = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); if (includeUri != null) request.removeAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); try { context.getRequestDispatcher(path).forward(request, response); } finally { if (includeUri != null) request.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, includeUri); } }
public Property readProperty(String xml) throws Exception { try { return readProperty(new StringReader(xml)); } catch (IOException e) { IllegalStateException ex = new IllegalStateException(e); ex.initCause(e); throw ex; } }
public Requirement readRequirement(String xml) throws Exception { try { return readRequirement(new StringReader(xml)); } catch (IOException e) { IllegalStateException ex = new IllegalStateException(e); ex.initCause(e); throw ex; } }
public Writer getResponseWriter() throws IllegalStateException { assertResponseAllowed(); try { return ((MimeResponse) response).getWriter(); } catch (IOException e) { IllegalStateException ise = new IllegalStateException("Unable to access the response Writer"); ise.initCause(e); throw ise; } }
public String writeRequirement(Requirement requirement) { try { StringWriter sw = new StringWriter(); writeRequirement(requirement, sw); return sw.toString(); } catch (IOException e) { IllegalStateException ex = new IllegalStateException(e); ex.initCause(e); throw ex; } }
public String writeResource(Resource resource) { try { StringWriter sw = new StringWriter(); writeResource(resource, sw); return sw.toString(); } catch (IOException e) { IllegalStateException ex = new IllegalStateException(e); ex.initCause(e); throw ex; } }
public String writeRepository(Repository repository) { try { StringWriter sw = new StringWriter(); writeRepository(repository, sw); return sw.toString(); } catch (IOException e) { IllegalStateException ex = new IllegalStateException(e); ex.initCause(e); throw ex; } }
public String writeProperty(Property property) { try { StringWriter sw = new StringWriter(); writeProperty(property, sw); return sw.toString(); } catch (IOException e) { IllegalStateException ex = new IllegalStateException(e); ex.initCause(e); throw ex; } }
/** * Creates a copy of the <TT>BitMatrix</TT>. * * @return a deep copy of the <TT>BitMatrix</TT> */ public Object clone() { try { BitMatrix c = (BitMatrix) super.clone(); c.rows = (BitVector[]) rows.clone(); for (int i = 0; i < rows.length; i++) c.rows[i] = (BitVector) rows[i].clone(); return c; } catch (CloneNotSupportedException e) { IllegalStateException ne = new IllegalStateException(); ne.initCause(e); throw ne; } }
/** * Add the DTD for the profileSet device * * @param profileSet Device Context * @param stream DTD data stream. */ public static void addDTD(ProfileSet profileSet, InputStream stream) { try { com.wutka.dtd.DTDParser parser = new com.wutka.dtd.DTDParser(new InputStreamReader(stream)); DTD dtd = parser.parse(); dtds.put(profileSet, dtd); } catch (Exception excep) { IllegalStateException state = new IllegalStateException("Error parsing dtd for [" + profileSet.getBaseProfile() + "]."); state.initCause(excep); throw state; } }
public Range getFullRange() { Range range = null; try { range = new Range(0, this.getNumberPoints() - 1); } catch (InvalidRangeException e) { IllegalStateException ise = new IllegalStateException( "Full trajectory range invalid <0, " + (this.getNumberPoints() - 1) + ">: " + e.getMessage()); ise.initCause(e); throw (ise); } return range; }
/** * Get the ClassContext for a class. * * @param javaClass the class * @return the ClassContext for that class */ public ClassContext getClassContext(JavaClass javaClass) { // This is a bit silly since we're doing an unnecessary // ClassDescriptor->JavaClass lookup. // However, we can be assured that it will succeed. ClassDescriptor classDescriptor = DescriptorFactory.instance() .getClassDescriptor(ClassName.toSlashedClassName(javaClass.getClassName())); try { return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor); } catch (CheckedAnalysisException e) { IllegalStateException ise = new IllegalStateException("Could not get ClassContext for JavaClass"); ise.initCause(e); throw ise; } }
/** * Subclasses can use this method to leave the authorization decision to the delegate configured */ protected int invokeDelegate(Resource resource) { int authorizationDecision = AuthorizationContext.DENY; ResourceType layer = resource.getLayer(); String delegateStr = (String) delegateMap.get(layer); if (delegateStr == null) throw PicketBoxMessages.MESSAGES.missingDelegateForLayer( layer != null ? layer.toString() : null); AuthorizationModuleDelegate delegate = null; try { delegate = getDelegate(delegateStr); authorizationDecision = delegate.authorize(resource, this.subject, this.role); } catch (Exception e) { IllegalStateException ise = new IllegalStateException(e.getLocalizedMessage()); ise.initCause(e); throw ise; } return authorizationDecision; }
/** * Check whether this project is currently modified including modifications to <code>project.xml * </code>. Access from GeneratedFilesHelper. */ void ensureProjectXmlUnmodified(String msg, boolean doSave) { assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess(); synchronized (modifiedMetadataPaths) { if (modifiedMetadataPaths.contains(PROJECT_XML_PATH)) { IllegalStateException ise = new IllegalStateException(msg); if (addedProjectXmlPath != null) { ise.initCause(addedProjectXmlPath); } LOG.log(Level.INFO, null, ise); if (doSave) { try { save(); } catch (IOException x) { LOG.log(Level.INFO, null, x); } } } } }
/** * Find a custom WebApplicationContext for this web application. * * @param sc ServletContext to find the web application context for * @param attrName the name of the ServletContext attribute to look for * @return the desired WebApplicationContext for this web app, or <code>null</code> if none */ public static WebApplicationContext getWebApplicationContext(ServletContext sc, String attrName) { Assert.notNull(sc, "ServletContext must not be null"); Object attr = sc.getAttribute(attrName); if (attr == null) { return DispatchServlet.webApplicationContext; } if (attr instanceof RuntimeException) { throw (RuntimeException) attr; } if (attr instanceof Error) { throw (Error) attr; } if (attr instanceof Exception) { IllegalStateException ex = new IllegalStateException(); ex.initCause((Exception) attr); throw ex; } if (!(attr instanceof WebApplicationContext)) { throw new IllegalStateException( "Context attribute is not of type WebApplicationContext: " + attr); } return (WebApplicationContext) attr; }
protected void postProcessBundleContext(BundleContext context) throws Exception { logger.debug("Post processing: creating test bundle"); Resource jar; Manifest mf = getManifest(); // if the jar content hasn't been discovered yet (while creating the manifest) // do so now if (jarEntries == null) { // set root path jarCreator.setRootPath(getRootPath()); // add the content pattern jarCreator.setContentPattern(getBundleContentPattern()); // use jar creator for pattern discovery jar = jarCreator.createJar(mf); } // otherwise use the cached resources else { jar = jarCreator.createJar(mf, jarEntries); } try { installAndStartBundle(context, jar); } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Unable to dynamically start generated unit test bundle"); ise.initCause(e); throw ise; } // now do the delegation super.postProcessBundleContext(context); }
private IllegalStateException handle(Exception e, String value) { IllegalStateException ex = new IllegalStateException("不支持编码类型[" + MYSQL_ENCODING + "],要编码的参数[" + value + "]"); ex.initCause(e); throw ex; }
public synchronized void start() throws Exception { if (channelClazz != null) { // Already started return; } if (useInvm) { channelClazz = LocalServerChannel.class; eventLoopGroup = new LocalEventLoopGroup(); } else { int threadsToUse; if (nioRemotingThreads == -1) { // Default to number of cores * 3 threadsToUse = Runtime.getRuntime().availableProcessors() * 3; } else { threadsToUse = this.nioRemotingThreads; } channelClazz = NioServerSocketChannel.class; eventLoopGroup = new NioEventLoopGroup( threadsToUse, new ActiveMQThreadFactory("activemq-netty-threads", true, getThisClassLoader())); } bootstrap = new ServerBootstrap(); bootstrap.group(eventLoopGroup); bootstrap.channel(channelClazz); final SSLContext context; if (sslEnabled) { try { if (keyStorePath == null && TransportConstants.DEFAULT_TRUSTSTORE_PROVIDER.equals(keyStoreProvider)) throw new IllegalArgumentException( "If \"" + TransportConstants.SSL_ENABLED_PROP_NAME + "\" is true then \"" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "\" must be non-null " + "unless an alternative \"" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "\" has been specified."); context = SSLSupport.createContext( keyStoreProvider, keyStorePath, keyStorePassword, trustStoreProvider, trustStorePath, trustStorePassword); } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Unable to create NettyAcceptor for " + host + ":" + port); ise.initCause(e); throw ise; } } else { context = null; // Unused } final AtomicBoolean warningPrinted = new AtomicBoolean(false); ChannelInitializer<Channel> factory = new ChannelInitializer<Channel>() { @Override public void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); if (sslEnabled) { SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(false); if (needClientAuth) engine.setNeedClientAuth(true); // setting the enabled cipher suites resets the enabled protocols so we need // to save the enabled protocols so that after the customer cipher suite is enabled // we can reset the enabled protocols if a customer protocol isn't specified String[] originalProtocols = engine.getEnabledProtocols(); if (enabledCipherSuites != null) { try { engine.setEnabledCipherSuites( SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); } catch (IllegalArgumentException e) { ActiveMQServerLogger.LOGGER.invalidCipherSuite( SSLSupport.parseArrayIntoCommandSeparatedList( engine.getSupportedCipherSuites())); throw e; } } if (enabledProtocols != null) { try { engine.setEnabledProtocols( SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); } catch (IllegalArgumentException e) { ActiveMQServerLogger.LOGGER.invalidProtocol( SSLSupport.parseArrayIntoCommandSeparatedList( engine.getSupportedProtocols())); throw e; } } else { engine.setEnabledProtocols(originalProtocols); } // Strip "SSLv3" from the current enabled protocols to address the POODLE exploit. // This recommendation came from // http://www.oracle.com/technetwork/java/javase/documentation/cve-2014-3566-2342133.html String[] protocols = engine.getEnabledProtocols(); Set<String> set = new HashSet<>(); for (String s : protocols) { if (s.equals("SSLv3") || s.equals("SSLv2Hello")) { if (!warningPrinted.get()) { ActiveMQServerLogger.LOGGER.disallowedProtocol(s); } continue; } set.add(s); } warningPrinted.set(true); engine.setEnabledProtocols(set.toArray(new String[0])); SslHandler handler = new SslHandler(engine); pipeline.addLast("ssl", handler); } pipeline.addLast(protocolHandler.getProtocolDecoder()); } }; bootstrap.childHandler(factory); // Bind bootstrap.childOption(ChannelOption.TCP_NODELAY, tcpNoDelay); if (tcpReceiveBufferSize != -1) { bootstrap.childOption(ChannelOption.SO_RCVBUF, tcpReceiveBufferSize); } if (tcpSendBufferSize != -1) { bootstrap.childOption(ChannelOption.SO_SNDBUF, tcpSendBufferSize); } if (backlog != -1) { bootstrap.option(ChannelOption.SO_BACKLOG, backlog); } bootstrap.option(ChannelOption.SO_REUSEADDR, true); bootstrap.childOption(ChannelOption.SO_REUSEADDR, true); bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true); bootstrap.childOption(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE); channelGroup = new DefaultChannelGroup("activemq-accepted-channels", GlobalEventExecutor.INSTANCE); serverChannelGroup = new DefaultChannelGroup("activemq-acceptor-channels", GlobalEventExecutor.INSTANCE); if (httpUpgradeEnabled) { // the channel will be bound by the Web container and hand over after the HTTP Upgrade // handshake is successful } else { startServerChannels(); paused = false; if (notificationService != null) { TypedProperties props = new TypedProperties(); props.putSimpleStringProperty( new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName())); props.putSimpleStringProperty(new SimpleString("host"), new SimpleString(host)); props.putIntProperty(new SimpleString("port"), port); Notification notification = new Notification(null, CoreNotificationType.ACCEPTOR_STARTED, props); notificationService.sendNotification(notification); } if (batchDelay > 0) { flusher = new BatchFlusher(); batchFlusherFuture = scheduledThreadPool.scheduleWithFixedDelay( flusher, batchDelay, batchDelay, TimeUnit.MILLISECONDS); } ActiveMQServerLogger.LOGGER.startedAcceptor(host, port, protocolsString); } }