List of usage examples for org.apache.http.util Args notNull
public static <T> T notNull(T t, String str)
From source file:de.vanita5.twittnuker.util.net.ssl.HostResolvedSSLConnectionSocketFactory.java
public HostResolvedSSLConnectionSocketFactory(final javax.net.ssl.SSLSocketFactory socketfactory, final String[] supportedProtocols, final String[] supportedCipherSuites, final X509HostnameVerifier hostnameVerifier) { this.socketfactory = Args.notNull(socketfactory, "SSL socket factory"); this.supportedProtocols = supportedProtocols; this.supportedCipherSuites = supportedCipherSuites; this.hostnameVerifier = hostnameVerifier != null ? hostnameVerifier : SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER; }
From source file:com.ok2c.lightmtp.impl.protocol.SendDataCodec.java
public SendDataCodec(final SMTPBuffers iobuffers, final int maxLineLen, final boolean enhancedCodes, final DataAckMode mode) { super();// www . j av a 2 s . com Args.notNull(iobuffers, "IO buffers"); this.iobuffers = iobuffers; this.maxLineLen = maxLineLen; this.mode = mode != null ? mode : DataAckMode.SINGLE; this.parser = new SMTPReplyParser(enhancedCodes); this.contentBuf = new SMTPInputBuffer(BUF_SIZE, LINE_SIZE); this.lineBuf = new CharArrayBuffer(LINE_SIZE); this.recipients = new LinkedList<String>(); this.codecState = CodecState.CONTENT_READY; }
From source file:net.dv8tion.jda.core.utils.IOUtil.java
/** * Provided as a simple way to fully read an InputStream into a byte[]. * <p>/*from w w w.j a v a2 s . com*/ * This method will block until the InputStream has been fully read, so if you provide an InputStream that is * non-finite, you're gonna have a bad time. * * @param stream * The Stream to be read. * @return * A byte[] containing all of the data provided by the InputStream * @throws IOException * If the first byte cannot be read for any reason other than the end of the file, * if the input stream has been closed, or if some other I/O error occurs. */ public static byte[] readFully(InputStream stream) throws IOException { Args.notNull(stream, "InputStream"); byte[] buffer = new byte[1024]; try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { int readAmount = 0; while ((readAmount = stream.read(buffer)) != -1) { bos.write(buffer, 0, readAmount); } return bos.toByteArray(); } }
From source file:com.ok2c.lightmtp.impl.protocol.PipeliningSendEnvelopCodec.java
@Override public void reset(final IOSession iosession, final ClientState sessionState) throws IOException, SMTPProtocolException { Args.notNull(iosession, "IO session"); Args.notNull(sessionState, "Session state"); this.writer.reset(); this.parser.reset(); this.recipients.clear(); this.codecState = CodecState.MAIL_REQUEST_READY; this.deliveryFailed = false; if (sessionState.getRequest() != null) { iosession.setEvent(SelectionKey.OP_WRITE); } else {/*from w w w . j ava2 s. co m*/ iosession.setEvent(SelectionKey.OP_READ); } }
From source file:com.liferay.sync.engine.session.SyncManagedHttpClientConnection.java
@Override public void sendRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); ensureOpen();/*from ww w.j av a 2 s. c om*/ HttpEntity entity = request.getEntity(); if (entity == null) { return; } OutputStream outputStream = null; try { outputStream = getOutputStream(request); entity.writeTo(outputStream); } finally { StreamUtil.cleanUp(outputStream); } }
From source file:com.mashape.galileo.agent.network.AnalyticsRetryHandler.java
@Override public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { Args.notNull(exception, "Exception parameter"); Args.notNull(context, "HTTP context"); if (executionCount > this.retryCount) { return false; }/*from w ww. j a v a2 s . c o m*/ if (this.nonRetriableClasses.contains(exception.getClass())) { return false; } else { for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) { if (rejectException.isInstance(exception)) { return false; } } } if (exception instanceof NoHttpResponseException | exception instanceof SocketException | exception instanceof NoHttpResponseException) { LOGGER.warn(String.format("flush rquest failed, Agent will try to resend the request. reson: (%s)", exception.getMessage())); return true; } final HttpClientContext clientContext = HttpClientContext.adapt(context); if (!clientContext.isRequestSent()) { LOGGER.debug("Agent will try to resend the request."); return true; } return false; }
From source file:com.ok2c.lightmtp.impl.protocol.AuthCodec.java
public AuthCodec(final SMTPBuffers iobuffers, final String username, final String password) { super();/* w w w . j a v a2 s .com*/ Args.notNull(iobuffers, "IO buffers"); this.iobuffers = iobuffers; this.parser = new SMTPReplyParser(); this.writer = new SMTPCommandWriter(); this.username = username; this.password = password; this.codecState = CodecState.AUTH_READY; this.lineBuf = new CharArrayBuffer(1024); }
From source file:gov.ic.geoint.bulleit.apache.UriPatternMatcher.java
/** * @deprecated (4.1) do not use//from w w w.j av a 2 s.c o m */ @Deprecated public synchronized void setHandlers(final Map<String, T> map) { Args.notNull(map, "Map of handlers"); this.map.clear(); this.map.putAll(map); }
From source file:com.ok2c.lightmtp.impl.protocol.SendLocalHeloCodec.java
@Override public void produceData(final IOSession iosession, final ClientState sessionState) throws IOException, SMTPProtocolException { Args.notNull(iosession, "IO session"); Args.notNull(sessionState, "Session state"); SessionOutputBuffer buf = this.iobuffers.getOutbuf(); switch (this.codecState) { case LHLO_READY: String helo = heloName;/*from w w w .ja v a 2 s .co m*/ if (helo == null) { helo = AddressUtils.resolveLocalDomain(iosession.getLocalAddress()); } SMTPCommand ehlo = new SMTPCommand("LHLO", helo); this.writer.write(ehlo, buf); this.codecState = CodecState.LHLO_RESPONSE_EXPECTED; break; } if (buf.hasData()) { buf.flush(iosession.channel()); } if (!buf.hasData()) { iosession.clearEvent(SelectionKey.OP_WRITE); } }