Java Code Examples for io.netty.util.internal.ObjectUtil#checkNotNull()

The following examples show how to use io.netty.util.internal.ObjectUtil#checkNotNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenSslEngine.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
@Override
public void putValue(String name, Object value) {
    ObjectUtil.checkNotNull(name, "name");
    ObjectUtil.checkNotNull(value, "value");

    Map<String, Object> values = this.values;
    if (values == null) {
        // Use size of 2 to keep the memory overhead small
        values = this.values = new HashMap<String, Object>(2);
    }
    Object old = values.put(name, value);
    if (value instanceof SSLSessionBindingListener) {
        ((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
    }
    notifyUnbound(old, name);
}
 
Example 2
Source File: OpenSslSessionContext.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the SSL session ticket keys of this context.设置此上下文的SSL会话票据密钥。
 */
public void setTicketKeys(OpenSslSessionTicketKey... keys) {
    ObjectUtil.checkNotNull(keys, "keys");
    SessionTicketKey[] ticketKeys = new SessionTicketKey[keys.length];
    for (int i = 0; i < ticketKeys.length; i++) {
        ticketKeys[i] = keys[i].key;
    }
    Lock writerLock = context.ctxLock.writeLock();
    writerLock.lock();
    try {
        SSLContext.clearOptions(context.ctx, SSL.SSL_OP_NO_TICKET);
        SSLContext.setSessionTicketKeys(context.ctx, ticketKeys);
    } finally {
        writerLock.unlock();
    }
}
 
Example 3
Source File: AbstractScheduledEventExecutor.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
    ObjectUtil.checkNotNull(command, "command");
    ObjectUtil.checkNotNull(unit, "unit");
    if (initialDelay < 0) {
        throw new IllegalArgumentException(
                String.format("initialDelay: %d (expected: >= 0)", initialDelay));
    }
    if (period <= 0) {
        throw new IllegalArgumentException(
                String.format("period: %d (expected: > 0)", period));
    }

    return schedule(new ScheduledFutureTask<Void>(
            this, Executors.<Void>callable(command, null),
            ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), unit.toNanos(period)));
}
 
Example 4
Source File: UkcpServerBootstrap.java    From kcp-netty with MIT License 5 votes vote down vote up
/**
 * Set the specific {@link AttributeKey} with the given value on every child {@link Channel}. If the value is
 * {@code null} the {@link AttributeKey} is removed
 */
public <T> UkcpServerBootstrap childAttr(AttributeKey<T> childKey, T value) {
    ObjectUtil.checkNotNull(childKey, "childKey");
    if (value == null) {
        childAttrs.remove(childKey);
    } else {
        childAttrs.put(childKey, value);
    }
    return this;
}
 
Example 5
Source File: DnsNameResolverContext.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
DnsNameResolverContext(DnsNameResolver parent,
                       String hostname,
                       DnsRecord[] additionals,
                       DnsCache resolveCache,
                       DnsServerAddressStream nameServerAddrs) {
    this.parent = parent;
    this.hostname = hostname;
    this.additionals = additionals;
    this.resolveCache = resolveCache;

    this.nameServerAddrs = ObjectUtil.checkNotNull(nameServerAddrs, "nameServerAddrs");
    maxAllowedQueries = parent.maxQueriesPerResolve();
    resolvedInternetProtocolFamilies = parent.resolvedInternetProtocolFamiliesUnsafe();
    allowedQueries = maxAllowedQueries;
}
 
Example 6
Source File: DnsNameResolverException.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private static DnsQuestion validateQuestion(DnsQuestion question) {
    return ObjectUtil.checkNotNull(question, "question");
}
 
Example 7
Source File: PemValue.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
public PemValue(ByteBuf content, boolean sensitive) {
    this.content = ObjectUtil.checkNotNull(content, "content");
    this.sensitive = sensitive;
}
 
Example 8
Source File: DefaultSmtpRequest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
DefaultSmtpRequest(SmtpCommand command, List<CharSequence> parameters) {
    this.command = ObjectUtil.checkNotNull(command, "command");
    this.parameters = parameters != null ?
            Collections.unmodifiableList(parameters) : Collections.<CharSequence>emptyList();
}
 
Example 9
Source File: Http2StreamChannelBootstrap.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
public Http2StreamChannelBootstrap(Channel channel) {
    this.channel = ObjectUtil.checkNotNull(channel, "channel");
}
 
Example 10
Source File: DefaultHttp2SettingsFrame.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
public DefaultHttp2SettingsFrame(Http2Settings settings) {
    this.settings = ObjectUtil.checkNotNull(settings, "settings");
}
 
Example 11
Source File: UniSequentialDnsServerAddressStreamProvider.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
UniSequentialDnsServerAddressStreamProvider(DnsServerAddresses addresses) {
    this.addresses = ObjectUtil.checkNotNull(addresses, "addresses");
}
 
Example 12
Source File: UnaryPromiseNotifier.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
public UnaryPromiseNotifier(Promise<? super T> promise) {
    this.promise = ObjectUtil.checkNotNull(promise, "promise");
}
 
Example 13
Source File: LineSeparator.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
/**
 * Create {@link LineSeparator} with the specified {@code lineSeparator} string.
 */
public LineSeparator(String lineSeparator) {
    this.value = ObjectUtil.checkNotNull(lineSeparator, "lineSeparator");
}
 
Example 14
Source File: AbstractBootstrapConfig.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
protected AbstractBootstrapConfig(B bootstrap) {
    this.bootstrap = ObjectUtil.checkNotNull(bootstrap, "bootstrap");
}
 
Example 15
Source File: PemPrivateKey.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private PemPrivateKey(ByteBuf content) {
    this.content = ObjectUtil.checkNotNull(content, "content");
}
 
Example 16
Source File: PromiseCombiner.java    From netty-4.1.22 with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Sets the promise to be notified when all combined futures have finished. If all combined futures succeed,
 * then the aggregate promise will succeed. If one or more combined futures fails, then the aggregate promise will
 * fail with the cause of one of the failed futures. If more than one combined future fails, then exactly which
 * failure will be assigned to the aggregate promise is undefined.</p>
 *
 * <p>After this method is called, no more futures may be added via the {@link PromiseCombiner#add(Future)} or
 * {@link PromiseCombiner#addAll(Future[])} methods.</p>
 *
 * @param aggregatePromise the promise to notify when all combined futures have finished
 *                         设定所有组合期货交易完成后的通知。如果所有联合期货都成功,那么总的承诺将成功。如果一个或多个联合期货失败,那么总的承诺将会因为其中一个失败期货的原因而失败。如果不止一个组合的未来失败,那么将分配给聚合承诺的具体失败是不确定的。
在调用此方法之后,不再可以通过add(Future)或addAll(Future)方法添加未来。
 */
public void finish(Promise<Void> aggregatePromise) {
    if (doneAdding) {
        throw new IllegalStateException("Already finished");
    }
    doneAdding = true;
    this.aggregatePromise = ObjectUtil.checkNotNull(aggregatePromise, "aggregatePromise");
    if (doneCount == expectedCount) {
        tryPromise();
    }
}
 
Example 17
Source File: SniHandler.java    From netty-4.1.22 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a SNI detection handler with configured {@link SslContext}
 * maintained by {@link AsyncMapping}
 * 使用配置的SslContext创建一个SNI检测处理程序,由异步映射维护
 *
 * @param mapping the mapping of domain name to {@link SslContext}
 */
@SuppressWarnings("unchecked")
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping) {
    this.mapping = (AsyncMapping<String, SslContext>) ObjectUtil.checkNotNull(mapping, "mapping");
}
 
Example 18
Source File: WebSocketChunkedInput.java    From netty-4.1.22 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance using the specified input.
 * @param input {@link ChunkedInput} containing data to write
 * @param rsv RSV1, RSV2, RSV3 used for extensions
 *
 * @throws  NullPointerException if {@code input} is null
 */
public WebSocketChunkedInput(ChunkedInput<ByteBuf> input, int rsv) {
    this.input = ObjectUtil.checkNotNull(input, "input");
    this.rsv = rsv;
}
 
Example 19
Source File: ApplicationProtocolNegotiationHandler.java    From netty-4.1.22 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance with the specified fallback protocol name.使用指定的回退协议名称创建一个新实例。
 *
 * @param fallbackProtocol the name of the protocol to use when
 *                         ALPN/NPN negotiation fails or the client does not support ALPN/NPN
 */
protected ApplicationProtocolNegotiationHandler(String fallbackProtocol) {
    this.fallbackProtocol = ObjectUtil.checkNotNull(fallbackProtocol, "fallbackProtocol");
}
 
Example 20
Source File: RedisEncoder.java    From netty-4.1.22 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance.
 * @param messagePool the predefined message pool.
 */
public RedisEncoder(RedisMessagePool messagePool) {
    this.messagePool = ObjectUtil.checkNotNull(messagePool, "messagePool");
}